-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey, thanks for your replies: they helped a lot.
Ravi schrieb:
> On Thursday 22 January 2009 05:51:20 Sebastian Walter wrote:
>> In my above case I know that *x won't be deleted because it is global,
>> right?
>
> *x is not deleted since you used PyArray_SimpleNewFromData; that *x is a
> global is irrelevant here.
>
>> Why exactly does the
>> *** glibc detected *** python: malloc(): memory corruption (fast):
>> 0x0817b6a1 ***
>> occur then?
>
> In the code you posted this time, incref() is required so that someone owns a
> reference to the array object. What I don't know off the top of my head is
> whether you need an incref in the constructor of A and a decref in the
> destructor of A.
This is also something I wondered about.
I guess it's better incref/decref them to be on the save side, right?
>
>> And is there a way to get the refcount of an object within Python? I'd
>> like to test if the refcount is correct.
>
> sys.getrefcount(obj)
Good to know. When I run
- ------------------- test.py ----------------
from _test import *
import sys
def test_my_array():
a = A()
print 'a.my_array=',a.my_array
print 'sys.getrefcount(a)=',sys.getrefcount(a)
print 'sys.getrefcount(a.my_array)=',sys.getrefcount(a.my_array)
if __name__ == "__main__":
test_my_array()
- ------------ end test.py -------------
I get the output
- ----------- output -------------
wal...@wronski$ python test.py
a.my_array= [ 1. 2. 3.]
sys.getrefcount(a)= 2
sys.getrefcount(a.my_array)= 2
- ----------- end output --------
Ermm, is that good?
I expected that the refcount would be 1 and not 2.
>
> Regards,
> Ravi
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/cplusplus-sig
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFJeZGL9PBA5IG0h0ARAg74AJ9yVUaruKo5XmsuDoCcmnyApZCUcACfdIig
R2c/WdZ08nayG/hWDkiDF8k=
=GY7d
-----END PGP SIGNATURE-----
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig