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.

Author rhettinger
Recipients rhettinger
Date 2015-05-18.01:05:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431911153.11.0.995728012143.issue24221@psf.upfronthosting.co.za>
In-reply-to
Content
The siftup() and siftdown() routines rearrange pointers in a list.  The generated code repeats the list object to ob_item lookup for each access.  This patch does that lookup only once per iteration.  It cleans up the code by replacing the PyList_GET_ITEM and PyList_SET_ITEM macros with normal array access (the usual way of presenting the algorithm).

This gives about a 5% speed-up using CLANG (timing heapify(data[:]) for n=1000 goes from .3441 per iteration to .3299).   However on GCC-4.9, the same patch gives a 2% slow-down (disassembly shows that this patch triggers a register spill and load in the inner loop which is a bummer).

Since it speeds-up some builds and slows down others, I'm uncertain what to do with this one.  I like the way the code reads with array accesses but was aiming for a consistent win.   Am posting the patch here to collect thoughts on the subject and to not lose the work.
History
Date User Action Args
2015-05-18 01:05:53rhettingersetrecipients: + rhettinger
2015-05-18 01:05:53rhettingersetmessageid: <1431911153.11.0.995728012143.issue24221@psf.upfronthosting.co.za>
2015-05-18 01:05:52rhettingerlinkissue24221 messages
2015-05-18 01:05:51rhettingercreate