Author brandtbucher
Recipients brandtbucher
Date 2022-01-12.22:50:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642027840.32.0.139240461948.issue46361@roundup.psfhosted.org>
In-reply-to
Content
To my surprise, it seems that it's possible to create "small" integers that should live in _PyLong_SMALL_INTS, but don't. Here are two examples I've found:

>>> import decimal
>>> i = int(decimal.Decimal(42))  # Modules/_decimal/_decimal.c:dec_as_long
>>> i
42
>>> i is 42
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False
>>> i = int.from_bytes(bytes([42]))  # Objects/longobject.c:_PyLong_FromByteArray
>>> i
42
>>> i is 42
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False

I'm not entirely sure if this is "allowed" or not, but in any case it seems beneficial to reach into the small ints here (provided it doesn't hurt performance, of course).

I'm testing out simple fixes for both of these now.
History
Date User Action Args
2022-01-12 22:50:40brandtbuchersetrecipients: + brandtbucher
2022-01-12 22:50:40brandtbuchersetmessageid: <1642027840.32.0.139240461948.issue46361@roundup.psfhosted.org>
2022-01-12 22:50:40brandtbucherlinkissue46361 messages
2022-01-12 22:50:40brandtbuchercreate