[Python-Dev] Caching function pointers in type objects

Daniel Stutzbach daniel at stutzbachenterprises.com
Wed Mar 3 22:57:54 CET 2010


On Wed, Mar 3, 2010 at 3:29 PM, Benjamin Peterson <benjamin at python.org>wrote:

> 2010/3/3 Daniel Stutzbach <daniel at stutzbachenterprises.com>:
> > I think I see a way to dramatically speed up PyObject_RichCompareBool
> when
> > comparing immutable, built-in, non-container objects (int, float, str,
> > etc.).  It would speed up list.sort when the key is one of those types,
> as
> > well as most operations on the ubiquitous dictionary with str keys.
>

(correcting myself)  I just noticed that CPython already optimizes
dictionaries with str-only keys and skips PyObject_RichCompareBool, so no
speed up there.  I think it would be redundant with optimization I have in
mind, so it could perhaps be taken out which would simplify the dict code a
bit and save a pointer in the dict structure.


> Perhaps you could explain what exactly you want to do. :) That would
> help us make a judgment.
>

It'd actually be a pretty small patch, so I think I should just explain it
by actually writing it. ;-)
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100303/2408026d/attachment-0001.html>


More information about the Python-Dev mailing list