[Python-Dev] Store startup modules as C structures for 20%+ startup speed improvement?
Guido van Rossum
guido at python.org
Fri Sep 21 13:35:45 EDT 2018
On Fri, Sep 21, 2018 at 8:16 AM Christian Heimes <christian at python.org>
wrote:
> On 21/09/2018 16.26, Guido van Rossum wrote:
> >> What about the small integers cache?
> >
> > I believe the small integers cache is only used to reduce the number of
> > objects -- I don't think there's any code (in CPython itself) that just
> > *assumes* that because an int is small it must be in the cache. So it
> > should be fine.
>
> Some places may assume that PyLong_FromLong() for a small int never
> fails. I certainly expect this in coverity scan modeling.
>
Ah, that goes in the other direction. That function will always return a
value from the cache if it's in range for the cache. and nothing change
there.
I was talking about situations where code might assume that if an object's
address is not that of the canonical cached zero-valued PyLong object, it
couldn't be a PyLong with value zero (same for other values in range of the
cache). I'd be very surprised if there was code assuming that, and I'd say
it was always wrong. (It's like beginners' code using 'x is 0' instead of
'x == 0'.)
Though now I start worrying about interned strings. That's a concept that's
a little closer to being a feature.
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180921/9772cf47/attachment.html>
More information about the Python-Dev
mailing list