473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getrefcou nt(11111111)
2
>>sys.getrefcou nt(11111111+1)
1
>>x=22222222
sys.getrefcou nt(x)
2
>>sys.getrefcou nt(x+1)
1
>>sys.getrefcou nt("A unique *str-ing*")
2
>>sys.getrefcou nt("A unique *str-ing*".upper())
1
>>sys.getrefcou nt(3+2j)
1
>>class W: pass
....
>>x=W()
sys.getrefcou nt(x)
2
>>sys.getrefcou nt(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.getrefcou nt(11111111)
3
>>sys.getrefcou nt(11111111+1)
2
>>x=22222222
sys.getrefcou nt(x)
2
>>sys.getrefcou nt(x+1)
1
>>sys.getrefcou nt("A unique *str-ing*")
3
>>sys.getrefcou nt("A unique *str-ing*".upper())
1
>>sys.getrefcou nt(3+2j)
2
>>class W: pass
....
>>x=W()
sys.getrefcou nt(x)
2
>>sys.getrefcou nt(W())
1
>>>
In particular, I wonder why getrefcount(123 41234) 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 928

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

Similar topics

1
1106
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 type(s) they are defining. I. e. from xxmodule.c: if (ErrorObject == NULL) { ErrorObject = PyErr_NewException("xx.error", NULL, NULL); if (ErrorObject == NULL)
0
1145
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 references are not getting released as they should and so on. As someone who's never done anything like this in the past, here's what I'm
13
9622
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 throughout, however the php powered html checker I have only caters for HTML 4.01 Strict. If possible I need to know the complete differences between Strict and Transitional so I can go through the php script and correctly set it up to properly...
4
1644
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: - simplify the garbage collector (according to the documentation, the GC is internally run twice) - do away with a lot of /using/ code dealing w/ instances that wrap externally accessible resources (files through StreamReader is a good example)
1
2573
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
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.