[issue1518] Fast globals/builtins access (patch)

Chris Mellon report at bugs.python.org
Thu Nov 29 17:07:37 CET 2007


Chris Mellon added the comment:

In funcobject.c:PyFunction_New, the declarations of op and __name__ need
to be moved to the top of the function to compile in MSVC, and if
accepted the fastglobals.c file needs to be added to PCBuild.

In the test script, the use of import * generates syntax warnings that
make the output awkward to read, and the benchmark for dict_get is
actually running dict_set. I'm attaching the fixed copy of the test
script I used.

I see roughly the same speed ups (MSVC 7.1, Windows XP, Intel Core2 Duo
@ 2.13Ghz), but I see a 10% slowdown in the dict-insert/delete and
dict-set benchmarks which I find very troubling.

Test            Trunk          fastglobals    Time difference
--------------------------------------------------
Dict insert/del 2.002495495    2.207409125    1.102329134
Dict get        0.750253205    0.745576662    0.993766714
Dict set        0.982695921    1.114997766    1.13463152
Local get       0.533387029    0.51337118     0.96247406
Local set       0.596565774    0.614124914    1.029433703
Global get      0.935605073    0.731136584    0.78145855
Global set      1.48638532     1.03868462     0.69879903
Builtin get     1.392606367    0.735180673    0.52791707
Function call   1.938705781    1.716233004    0.885246756
List comp       1.547780105    1.188215756    0.767690289


PyBench shows an overall slowdown - String mappings in particular,
string/unicode predicates, and new instance creation all show
significant slowdowns. The results are fairly verbose so I've uploaded
them as a google docs spreadsheet at
http://spreadsheets.google.com/ccc?key=p7g0z40g_NpvH5UpPTpr-Ag&hl=en

I notice that you create a new PyFastGlobals object in every call to
PyEval_EvalCode. This might explain some of the general case slowdown,
is this really what you want to do?

----------
nosy: +arkanes
Added file: http://bugs.python.org/file8823/fastglobals_test.py

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1518>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fastglobals_test.py
Type: text/x-python
Size: 12364 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-bugs-list/attachments/20071129/9a157d5e/attachment-0001.py 


More information about the Python-bugs-list mailing list