[Q] Overhead for lists as properties?
Roeland Rengelink
r.b.rigilink at chello.nl
Fri Dec 7 10:21:30 EST 2001
Oliver Hofmann wrote:
>
> 'lo everyone!
>
> Trying to figure out why appending to a list that is a class property
> takes so much longer than appending to a class attribute; this seems
> not to be the case for getting or setting other class attributes like
> integers.
>
> [snip results]
First of all, to let properties work as expected, the Tester classes
should be new-style classes
(derived from object, for example). If I do that, I get:
100043 function calls in 7.330 CPU seconds
Ordered by: internal time
List reduced from 12 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
5 2.560 0.512 3.770 0.754
prof_prop.py:41(testSettingPropList)
5 2.060 0.412 3.100 0.620
prof_prop.py:31(testSettingProp)
50000 1.210 0.000 1.210 0.000 prof_prop.py:18(getB)
50000 1.040 0.000 1.040 0.000 prof_prop.py:15(setA)
5 0.270 0.054 0.270 0.054
prof_prop.py:36(testSettingNormList)
5 0.150 0.030 0.150 0.030
prof_prop.py:26(testSettingNorm)
1 0.040 0.040 7.330 7.330 prof_prop.py:46(main)
10 0.000 0.000 0.000 0.000 prof_prop.py:9(__init__)
0 0.000 0.000 profile:0(profiler)
10 0.000 0.000 0.000 0.000 prof_prop.py:4(__init__)
Pretty much what you would expect. Half the overhead seems to be in
executing the additional Python code in getB and setA respectively. A
similar overhead is in finding and setting up the functions.
Hope this helps
Roeland
--
r.b.rigilink at chello.nl
"Half of what I say is nonsense. Unfortunately I don't know which half"
More information about the Python-list
mailing list