Skip to content

Instantly share code, notes, and snippets.

@pzp1997
Created June 6, 2016 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pzp1997/5d7f788bb0f3006d9228e557b7197fba to your computer and use it in GitHub Desktop.
Save pzp1997/5d7f788bb0f3006d9228e557b7197fba to your computer and use it in GitHub Desktop.
Excerpt from source code for Python int objects about caching "small" int values.
#ifndef NSMALLPOSINTS
#define NSMALLPOSINTS 257
#endif
#ifndef NSMALLNEGINTS
#define NSMALLNEGINTS 5
#endif
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
/* References to small integers are saved in this array so that they
can be shared.
The integers that are saved are those in the range
-NSMALLNEGINTS (inclusive) to NSMALLPOSINTS (not inclusive).
*/
static PyIntObject *small_ints[NSMALLNEGINTS + NSMALLPOSINTS];
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment