Performance penalty for using properties?
Joe Mason
joe at notcharles.ca
Sat Mar 13 12:57:20 EST 2004
In article <mailman.350.1079165978.19534.python-list at python.org>, Mike C. Fletcher wrote:
> Kenneth McDonald wrote:
> ...
>
>>Can anyone comment on the performance
>>costs associated with properties vs. simple attribute lookup?
>>
>>
> They can become a significant fraction of total run-time, and often wind
> up showing as the heaviest methods in an entire application if they are
> used pervasively (i.e. every attribute of every object is a property).
> Even short runs of small systems so designed can give you 100s of 1000s
> of calls to an individual method. OpenGLContext gets around this by
> defining an accelerator for the __get__ method of the field properties.
What does "accelerator" mean in this context? Obviously, it's something
that speeds up __get__ calls, but ihow is that accomplished?
If it's a simple wrapper, that means you can blissfully ignore property
costs until profiling shows it's a problem, which is a big win.
Joe
More information about the Python-list
mailing list