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

Stephen Vavasis vavasis at cpu111.math.uwaterloo.ca
Thu May 14 13:25:00 EDT 2009


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.  (I suppose I 
could change it to the new value via an increment or decrement, but this 
is ugly as well as being susceptible to overflow problems and roundoff 
errors in the case of floats.)

Thanks,
Steve Vavasis



More information about the Python-list mailing list