I took another quick look at performance of things, when I tested tuple-inherited vector performance, I had a typo - tuples were somewhat faster than having a list member (20%)
On 8/12/06, Marius Gedminas <[EMAIL PROTECTED]> wrote:
You can find my Vector class here: http://mg.pov.lt/pyspacewar/trac/browser/trunk/src/pyspacewar/world.py
The class marius linked to was about 3x faster than what I originally posted to the cookbook on a simple (vector - vector)*scalar, the 2 differences were inheriting from tuple & that Marius' class has add & sub always be vector & vector, and mul and div always be scalar and vector, while the class I posted using a try-catch to try and do every op as vector X vector, and fallback to vector X scalar (so vector X scalar ops went really slow because of the catch clause) ... also I tried making some dummy class that implement the math operators as a no-op that just returns the original object, the idea being that the performance of that would represent the best you could possibly get out of a vector class, and on my test it was 1/3rdth the speed of just doing math on the variables and 1/0th the speed of just doing math on variables when using psycho. Also, it was around 2x as fast as the fastest Vector class I tested - reiterating that using any vector class is slow, and to go fast you'll just need to rewrite your performance sensitive inner loops with some other approach.