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
  Clear Cache Path sportcardinal 0 254 Jul-05-2020, 05:11 PM
Last Post: sportcardinal
  How to print cache from Decorators with Memoization OlgaM 2 524 Jan-29-2020, 05:06 PM
Last Post: OlgaM
  pip cache millpond 3 3,979 Jul-22-2019, 01:12 AM
Last Post: millpond
  Error in request, cache key a21250450 2 1,078 Apr-02-2019, 11:20 AM
Last Post: a21250450
  Small help for the python array save juniorcoder 1 779 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 1,724 Aug-31-2018, 12:16 PM
Last Post: perfringo
  How to sum up the elements of an integer using python split/join? mohanraj1986 5 1,100 Aug-27-2018, 09:13 AM
Last Post: perfringo
  Clear cache blackclover 0 1,270 May-09-2018, 12:13 AM
Last Post: blackclover
  How to convert character to integer in python rajeev1729 2 1,737 Oct-03-2017, 04:30 PM
Last Post: nilamo
  How to map character to integer in python rajeev1729 1 2,134 Oct-02-2017, 01:41 PM
Last Post: buran

Forum Jump:

User Panel Messages

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