News for hackers. Stuff that matters.
Re:Python performance is a fool's errand by viraptor on Monday August 17, 2009 @01:05PM (#768526)
I'm not sure if that's a low upper-bound. He's complaining about an attribute access speed - but he's not trying to fix it... missed a great opportunity for __dict__ usage.

From a quick py2.5 benchmark:

    noop 0.3s
    class_create 0.76s
    with_dict 1.68s
    without_dict 2.06s
Functions tested 1,000,000 times - noop is an empty function for comparison; class_create is just x=A(); with_dict and without_dict create a class each time, assign 3 attributes, then read the same 3 attributes. with_... does it on an object that lists the attributes in __dict__, the other one doesn't use __dict__ and assigns attributes in the constructor.

So... 1s (without the constructor and loop time) for 3,000,000 attribute reads and 3,000,000 attribute writes. Slow? Is he sure that it's the attribute read and write that's causing the problems? I'm not sure if I believe that without some more details - especially if he works with some documents that look like they're on some external storage (disk / db / whatever).

There are no comments on this comment yet.