<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Sep 21, 2018 at 8:16 AM Christian Heimes <<a href="mailto:christian@python.org">christian@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 21/09/2018 16.26, Guido van Rossum wrote:<br>
>> What about the small integers cache?<br>
> <br>
> I believe the small integers cache is only used to reduce the number of<br>
> objects -- I don't think there's any code (in CPython itself) that just<br>
> *assumes* that because an int is small it must be in the cache. So it<br>
> should be fine.<br>
<br>
Some places may assume that PyLong_FromLong() for a small int never<br>
fails. I certainly expect this in coverity scan modeling.<br></blockquote><div><br></div><div>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.<br></div><div><br></div><div>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'.)<br></div><div><br></div><div>Though now I start worrying about interned strings. That's a concept that's a little closer to being a feature.<br></div></div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div></div>