[Python-Dev] default of returning None hurts performance?
Gregory P. Smith
greg at krypto.org
Tue Sep 1 00:07:49 CEST 2009
More information about the Python-Dev mailing list
Tue Sep 1 00:07:49 CEST 2009
- Previous message: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?
- Next message: [Python-Dev] default of returning None hurts performance?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Aug 31, 2009 at 2:20 PM, Antoine Pitrou <solipsis at pitrou.net> wrote: > Gregory P. Smith <greg <at> krypto.org> writes: > > > > food for thought as noticed by a coworker who has been profiling some hot > code > to optimize a library...If a function does not have a return statement we > return > None. Ironically this makes the foo2 function below faster than the bar2 > function at least as measured using bytecode size > > I would be surprised if this "bytecode size" difference made a significant > difference in runtimes, given that function call cost should dwarf the > cumulated > cost of POP_TOP and LOAD_CONST (two of the simplest opcodes you could > find). > > the attached sample code repeatably shows that it makes a difference though its really not much of one (2-3%). I was just wondering if a bytecode for a superinstruction of the common sequence: 6 POP_TOP 7 LOAD_CONST 0 (None) 10 RETURN_VALUE might be worth it. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20090831/48320427/attachment-0001.htm> -------------- next part -------------- A non-text attachment was scrubbed... Name: none_speed.py Type: text/x-python Size: 619 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20090831/48320427/attachment-0001.py>
- Previous message: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?
- Next message: [Python-Dev] default of returning None hurts performance?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list