C API: how to replace python number object in place?

Hrvoje Niksic hniksic at xemacs.org
Thu May 14 22:59:29 CEST 2009


vavasis at cpu111.math.uwaterloo.ca (Stephen Vavasis) writes:

> If x is a C variable of type PyObject*, and I happen to know already
> that the object is of a numeric type, say int, is there a way to
> change the value of x in place to a different number?  In the C/API
> documentation I found routines to increment or decrement it in
> place, but I didn't find a routine to simply replace its value by a
> different value.

The only thing you can do is change x to point to a different object,
with the new desired value.  That is how the "in place" number
modification functions work.

Which routines to increment or decrement the number are you referring
to, exactly?



More information about the Python-list mailing list