Repository navigation
Conversation
This optimization was added in 1993 (commit 842d2cc), and we've been running with it ever since. I think at this point it's fair to say that it's no longer experimental. That lets us simplify the code by removing a number of `#ifdef`s. In particular this will help us simplify the usage of CHECK_SMALL_INT.
aeros
reviewed
Aug 10, 2019
| @@ -0,0 +1,6 @@ | |||
| The "small int" optimization is now unconditionally enabled. This | |||
| optimization was introduced in Python 1.0.1, and means that :class:`int` | |||
| values from -5 to 256 are pre-initialized rather than constructed on demand. | |||
Contributor
There was a problem hiding this comment.
I think it is worthwhile to mention that this range is inclusive. Otherwise, users might assume that the maximum is 255 instead of 256, or that the minimum is -4 instead of -5. I've seen this range most commonly notated with [-5, 257), but I think adding "(inclusive)" after it is probably more appropriate and easy to understand for a news entry.
Suggested change
| values from -5 to 256 are pre-initialized rather than constructed on demand. | |
| values from -5 to 256 (inclusive) are pre-initialized rather than constructed on demand. |
Contributor
Author
There was a problem hiding this comment.
Sure, thanks. I don't want to make a big deal of the exact numbers because it's not something it makes sense for people to depend on -- but it's a natural question for a reader to be curious about. I made it "-5 through 256", which I think is unambiguous while staying unobtrusive.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This optimization was added in 1993 (commit 842d2cc), and we've
been running with it ever since. I think at this point it's fair
to say that it's no longer experimental. That lets us simplify
the code by removing a number of
#ifdefs.In particular this will help us simplify the usage of CHECK_SMALL_INT.
https://bugs.python.org/issue37812