473,543 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debugging reference counts in python/C

Hello everybody

I am trying to make sure that my (non trivial) C module is cleaning up
properly after itself, and consequently I've built python with
--py-debug which, besides allowing me to use certain functions, it also
prints the reference count at the end.

I am finding, however, that the reference count on exit seems to
increase by 1 every time I create one of my objects, poring over the
output of the debugging functions seems to imply that the only thing
that changes is the refcount of

[somenumber] '<dummy key>'

where somenumber seems proportional to the number of objects I create,
if I create n+1 objects, somenumber increases by 1. Looking at the docs
this seems related to empty dictionaries, but I'm really stumped at the
moment.

Out of curiosity I also did this stupid test thinking it would return
the same refcount, but evidently it doesn't:

Type "help", "copyright" , "credits" or "license" for more information.
>>a=1
[17214 refs]
>>(ctrl-D)
[17214 refs]
[6606 refs]

Type "help", "copyright" , "credits" or "license" for more information.
>>a=1
[17214 refs]
>>b=2
[17217 refs]
>>(ctrl-D)
[17217 refs]
[6608 refs]

as you can see just assigning another variable causes the refcount to
remain higher when python exits.

Is this something I should be worried about at all? I am new to writing
python C extensions, and that's why I never really worried about all
this before; apologies if my question is obvious and/or trivial...

Aug 30 '06 #1
0 1193

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

Similar topics

6
2166
by: Elbert Lev | last post by:
Please correct me if I'm wrong. Python (as I understand) uses reference counting to determine when to delete the object. As soon as the object goes out of the scope it is deleted. Python does not use garbage collection (as Java does). So if the script runs a loop: for i in range(100): f = Obj(i)
6
2243
by: Chris S. | last post by:
I'm trying to make a graphical editor and browser for Pickled files. One aspect I'm not sure about is how to detect multiple references to the same data. For instance, say I had the Pickled data: a= b= c= d=
25
4260
by: Jeff | last post by:
Use the MS Script Editor included free with MS Office 2002 and above, for debugging Internet Explorer (IE). This subject is of great interest to many JS developers, as there is no obvious, low cost way to do sophisticated debugging in IE6 other than to use the debugger described below, which is horribly documented otherwise. I feel...
13
2911
by: python | last post by:
hello and thanks for reading this, i have been a dos/windows user using some form of the basic language for 30 years now. i own and run a small programming company and there is one feature that keeps me in the windows/basic world. while i will agree that it has not evolved well, it does have one awesome feature that i have yet to see...
1
2051
by: Wildemar Wildenburger | last post by:
.... how? I'm writing an app that holds a public data dictionary from which other objects obtain part of their __dict__ values so they all work on the same dataset (yes I'm fiendishly clever and a constructor of unreadable sentences (and code) ;)). My problem is that I haven't found an easy way to determine if said dictionary contents...
20
4160
by: krypto.wizard | last post by:
Is there any editor or IDE in Python (either Windows or Linux) which has very good debugging facilites like MS VisualStudio has or something like that. I like SPE but couldn't easily use winPDP. I need tips to debug my code easily. Every help is greatly appreciated. Thanks
5
1423
by: raghu | last post by:
Hi All, I am a new user of Python and am having a bit of problem understanding the Reference counting and memory leakage issues. Requesting help from experienced users.... I wrote the following simple program.
0
880
by: David Coffin | last post by:
Hi, Is there any documentation concerning the Python debugging builds beyond section 1.5 in the Python/C API reference manual and Misc/ SpecialBuilds.txt file in the source code? I'd like to know how people generally go about debugging memory leaks in C extensions. Thanks,
16
1161
by: Niels L Ellegaard | last post by:
Is there a module that allows me to find errors that occur due to copy by reference? I am looking for something like the following: Traceback (most recent call last): File "<stdin>", line 1, in ? CopyByReferenceError: Variable b refers to variable a, so please do not change variable a. Does such a module exist? Would it be possible to...
0
7412
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7748
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...
1
7356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7697
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...
0
4900
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...
1
1830
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
0
648
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...

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.