This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: simplify cell var initialization by storing constant data on the code object
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, jcea, loewis, ncoghlan, python-dev
Priority: normal Keywords: patch

Created on 2011-06-24 16:05 by benjamin.peterson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bettercells.patch benjamin.peterson, 2011-06-24 16:05 review
x.py benjamin.peterson, 2011-06-24 17:45
bettercells2.patch benjamin.peterson, 2011-06-25 01:00 review
Messages (11)
msg138956 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-06-24 16:05
Initializing cell variables currently involves 2 nested loops every function call. This patch makes that process much more efficient by saving information which doesn't change every function call to the code object.
msg138963 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2011-06-24 16:57
Could you possibly post a before/after timing comparison?. Some realistic code... Post the test code too.

And yes, I know that the difference will depend of code, and hardware architecture. But some references are better that not reference at all.
msg138964 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-06-24 17:04
2011/6/24 Jesús Cea Avión <report@bugs.python.org>:
>
> Jesús Cea Avión <jcea@jcea.es> added the comment:
>
> Could you possibly post a before/after timing comparison?. Some realistic code... Post the test code too.
>
> And yes, I know that the difference will depend of code, and hardware architecture. But some references are better that not reference at all.

Well, I don't really care whether it's faster or not. It's much nicer
looking now, though.
msg138966 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2011-06-24 17:23
Then change the issue title :-p.
msg138969 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-06-24 17:45
The attached highly braindead benchmark reports about a 2% improvement.
msg139006 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-06-25 00:17
Reviewed. General concept looks sound, just suggested a few tweaks around the edges.

And issue title updated appropriately :)
msg139014 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-06-25 01:00
Thanks for the review.
msg139023 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-06-25 08:02
Feel free to create a new issue about the incorrect size calculation on code objects, since it is apparently already broken.
msg139143 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-06-26 03:54
New changeset c5b0585624ef by Benjamin Peterson in branch 'default':
map cells to arg slots at code creation time (closes #12399)
http://hg.python.org/cpython/rev/c5b0585624ef
msg166513 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-07-26 20:21
See issue15456 for a follow-up issue.
msg166515 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-26 20:23
New changeset 5093cfdff2a9 by Martin v. Löwis in branch 'default':
Issue #15456: Fix code __sizeof__ after #12399 change.
http://hg.python.org/cpython/rev/5093cfdff2a9
History
Date User Action Args
2022-04-11 14:57:18adminsetgithub: 56608
2012-07-26 20:23:39python-devsetmessages: + msg166515
2012-07-26 20:21:47loewissetnosy: + loewis
messages: + msg166513
2011-06-26 03:54:52python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg139143

resolution: fixed
stage: patch review -> resolved
2011-06-25 08:02:50ncoghlansetmessages: + msg139023
2011-06-25 01:00:58benjamin.petersonsetfiles: + bettercells2.patch

messages: + msg139014
2011-06-25 00:17:20ncoghlansetmessages: + msg139006
title: make cell var initialization more efficient -> simplify cell var initialization by storing constant data on the code object
2011-06-24 17:45:30benjamin.petersonsetfiles: + x.py

messages: + msg138969
2011-06-24 17:23:46jceasetmessages: + msg138966
2011-06-24 17:04:41benjamin.petersonsetmessages: + msg138964
2011-06-24 16:57:33jceasetmessages: + msg138963
2011-06-24 16:54:04jceasetnosy: + jcea
2011-06-24 16:05:59benjamin.petersoncreate