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

Home Posts Topics Members FAQ

Int tuple element scope

Can anyone tell me why the following will cause the returned tuple elements to remain un collected when the tuple goes out of scope:

PyObject * iobj = PyObject_New( PyIntObject, &PyInt_Type );
iobj->ob_ival = val;
PyTuple_SetItem ( tuple, index, iobj );
return tuple;

while the following will collect the elements:

PyTuple_SetItem ( tuple, index PyInt_FromLong( val ) );
return tuple;

both PyObject_New and PyInt_FromLong return new references and I have verified that in all cases the refcount upon return is 1 for all objects involved. So I'm just wondering if I'm missing something fundamental.

Thanks in advance!

Ron
Jul 18 '05 #1
0 1369

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

Similar topics

4
9184
by: Alastair G. Hogge | last post by:
Hello *, I'm using Python and the cgi module to retrive data from a HTML form. I'm then trying to get that information into a string. But efforts fail when I run type(foo) on my string. type() returns tuple. My codes follows: #!/usr/local/bin/python import cgi
50
3676
by: Will McGugan | last post by:
Hi, Why is that a tuple doesnt have the methods 'count' and 'index'? It seems they could be present on a immutable object. I realise its easy enough to convert the tuple to a list and do this, I'm just curious why it is neccesary.. Thanks,
1
2147
by: richard | last post by:
bonjour je me connecte à une base de données interbase/firebird en utilisant, KinterbasDB http://kinterbasdb.sourceforge.net/ pour ceux que ca interesse mais je pense que le probleme est le meme quel que soit la bdd j'aimerais acceder a un champs par sont nom plutot que par son index dans le record en cours, comme je fais maintenent
37
2372
by: Gregor Horvath | last post by:
Hi, >>>type() <type 'list'> >>>type(('1')) <type 'str'> I wonder why ('1') is no tuple????
62
20179
by: John Salerno | last post by:
Yes, silly question, but it keeps me up at night. :) I know it comes from the suffix -tuple, which makes me think it's pronounced as 'toople', but I've seen (at m-w.com) that the first pronunciation option is 'tuhple', so I wasn't sure. Maybe it's both, but which is most prevalent? Thanks! Now time to go back to reading the chapter on tuples...
77
4411
by: Nick Maclaren | last post by:
Why doesn't the tuple type have an index method? It seems such a bizarre restriction that there must be some reason for it. Yes, I know it's a fairly rare requirement. Regards, Nick Maclaren.
1
2870
by: Giovanni Toffoli | last post by:
Hi, I'm not in the mailing list. By Googling, I stepped into this an old post: (Thu Feb 14 20:40:08 CET 2002) of Jeff Shannon: http://mail.python.org/pipermail/python-list/2002-February/128438.html <<< def SortOnItem(mylist, index): templist = , line) for line in mylist ]
4
1637
by: wxPythoner | last post by:
To create a tuple with one element, you need to do this: <type 'tuple'> But if you do this <type 'int'> you don't get a tuple. I thought that just putting a value inside ( )
4
2421
by: Alex Vinokur | last post by:
Here is some tuple (triple in this case) with uniform types (for instance, double): boost::tuple<double, double, doublet; Is there any way (in boost::tuple) to define such tuples something like uniform_tuple <3, doublet; ? Alex Vinokur
0
8305
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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
6163
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
4151
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
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
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.