Python Forum
python cache for small integer
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python cache for small integer
#1
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)
3
>>>
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
Reply
#2
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 - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Speeding up code using cache Peter 1 512 Jul-29-2023, 04:52 AM
Last Post: bowlofred
  Opinion: how should my scripts cache web download files? stevendaprano 0 701 Dec-17-2022, 12:19 AM
Last Post: stevendaprano
Question Opening small size browser with python selenium not work, need help greenpine 0 1,586 Feb-07-2022, 11:36 AM
Last Post: greenpine
  Python Regular expression, small sample works but not on file Acernz 5 2,858 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 2,490 May-24-2021, 08:48 AM
Last Post: bowlofred
  main libvlc error: stale plugins cache: schascheck 2 7,594 Dec-27-2020, 05:24 PM
Last Post: schascheck
  Clear Cache Path sportcardinal 0 1,580 Jul-05-2020, 05:11 PM
Last Post: sportcardinal
  How to print cache from Decorators with Memoization OlgaM 2 2,015 Jan-29-2020, 05:06 PM
Last Post: OlgaM
  Beginner at Python. Trying to count certain integer from random string of code kiaspelleditwrong 3 2,367 Oct-14-2019, 10:40 AM
Last Post: perfringo
  pip cache millpond 3 8,153 Jul-22-2019, 01:12 AM
Last Post: millpond

Forum Jump:

User Panel Messages

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