473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

refcount differences in 2.5

Hi

With Python 2.5, there is a change on the reference count of objects
compared with previous versions (as reported by sys.getrefcount).

All Python versions from 2.1 thru 2.4 gave these same results:

Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>import sys
sys.getrefcount(11111111)
2
>>sys.getrefcount(11111111+1)
1
>>x=22222222
sys.getrefcount(x)
2
>>sys.getrefcount(x+1)
1
>>sys.getrefcount("A unique *str-ing*")
2
>>sys.getrefcount("A unique *str-ing*".upper())
1
>>sys.getrefcount(3+2j)
1
>>class W: pass
....
>>x=W()
sys.getrefcount(x)
2
>>sys.getrefcount(W())
1
>>>
But Python 2.5 (2.5.1 not tested yet) gives different results:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
on win
32
>>import sys
sys.getrefcount(11111111)
3
>>sys.getrefcount(11111111+1)
2
>>x=22222222
sys.getrefcount(x)
2
>>sys.getrefcount(x+1)
1
>>sys.getrefcount("A unique *str-ing*")
3
>>sys.getrefcount("A unique *str-ing*".upper())
1
>>sys.getrefcount(3+2j)
2
>>class W: pass
....
>>x=W()
sys.getrefcount(x)
2
>>sys.getrefcount(W())
1
>>>
In particular, I wonder why getrefcount(12341234) returns 3 instead of 2-
who is holding the extra reference?

My main two concerns are:
- is there a reference leak somewhere?
- it's a bit harder to debug my own references since I don't know
beforehand the value I should expect from sys.getrefcount()

--
Gabriel Genellina

May 16 '07 #1
0 919

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ames Andreas (MPA/DF) | last post by:
Hi all, I'm currently building an extension module by hand and am confused by the fact that as well xxmodule.c as structmodule.c and other examples increment the refcount of the exception...
0
by: Jean-François Doyon | last post by:
Hello, I'm working with Zope 2.7 and Python 2.3.3, and I have some leaks I'm trying to track down. So, more generally, I'm wondering what might be good techniques to track down where...
13
by: Kieran | last post by:
I am designing a content management system and I want to make sure all pages entered into it's database by users are using valid HTML. I have designed the system to use HTML 4.01 Transitional...
4
by: Julie | last post by:
Does anyone know why the Finalize method (if present) isn't called immediately after the instance refcount is set to 0? It seems to me, that if it were, it would solve at least two issues: -...
1
by: Simon Pickles | last post by:
Hi, Is is possible to access the refcount for an object? Ideally, I am looking to see if I have a refcount of 1 before calling del Thanks Simon
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.