473,382 Members | 1,389 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,382 software developers and data experts.

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 1187

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

Similar topics

6
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...
6
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...
25
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...
13
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...
1
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...
20
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....
5
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...
0
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...
16
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.