[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] 2D vector class



On 8/14/06, Alex Holkner <aholkner@xxxxxxxxxxxxxx> wrote:
Thanks Brian for writing the very useful benchmark script, I'll be
keeping an eye on it during development.  I expect you'll get the same
performance I am if you use __slots__, a minor change.

Hmmm.. I had tried using __slots__ on the class early on, thinking it
would potentially be the best python thing you could do because then
your attributes are allocated in your object... when I tested it on
python 2.3 on WinXP it seemed to be about the same performance as
using a list member... it disappointed me at the time because I really
thought it was the best way to go...

... but maybe performance sucked cause the operators were still using
[] access on other vec2d's, I noticed the euclid code is using x & y
on other vec2d's with an if (so it can still support adding with
anything with a list interface...)

now I'll have to look at slots again :)