Python Forum
python cache for small integer
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python cache for small integer
I know there is a cache to hold for small integers [-5,256] but when i try to get reference count for a big number like:
>>> import sys
>>> sys.getrefcount(2323232323)
Why the result is 3 ? Are there some "internal variables" hold this value inside python ?. It doesn't make sense, i thought a new value is only created when we make a new assignment(expect for those in [-5,256])in our script.Furthermore, how can python's garbage collector collect these value ? Because they always have "internal variables" point to them and their reference counter never drop to 0 .Please help me out, guys Sad
It looks like the three includes the reference in the getrefcount call, one in the interactive interpreter, and one for optimization purposes. See this stack overflow.
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Regular expression, small sample works but not on file Acernz 5 635 Jun-09-2021, 08:27 PM
Last Post: bowlofred
  Question about change hex string to integer sting in the list (python 2.7) lzfneu 1 636 May-24-2021, 08:48 AM
Last Post: bowlofred
  main libvlc error: stale plugins cache: schascheck 2 2,608 Dec-27-2020, 05:24 PM
Last Post: schascheck
  Clear Cache Path sportcardinal 0 662 Jul-05-2020, 05:11 PM
Last Post: sportcardinal
  How to print cache from Decorators with Memoization OlgaM 2 961 Jan-29-2020, 05:06 PM
Last Post: OlgaM
  Beginner at Python. Trying to count certain integer from random string of code kiaspelleditwrong 3 1,134 Oct-14-2019, 10:40 AM
Last Post: perfringo
  pip cache millpond 3 6,278 Jul-22-2019, 01:12 AM
Last Post: millpond
  Error in request, cache key a21250450 2 1,707 Apr-02-2019, 11:20 AM
Last Post: a21250450
  Small help for the python array save juniorcoder 1 1,239 Sep-27-2018, 09:28 AM
Last Post: buran
  Python function that uses a word as the encryption key, rather than an integer wak_stephanie 4 2,672 Aug-31-2018, 12:16 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020