passing PyIntType objects by reference

Peter Otten __peter__ at
Thu Jun 10 19:18:54 CEST 2004

Patrick Stinson wrote:

> when passing an python integer value to a C function
> ie.
> x = 1
> mymod.myfunc(x)
> is it possible to change the value of the python object "x" as happens in
> c when you pass a pointer to an int? Is there something fundamentally
> wrong with this idea, as this does not happen in pure python anyway?

>>> a = 1
>>> b = 1
>>> a is b

If you somehow manage to change a's value into 42, you will change every 1
to 42.


More information about the Python-list mailing list