The "does Python have variables?" debate

Rustom Mody rustompmody at gmail.com
Fri May 9 12:07:46 EDT 2014


On Friday, May 9, 2014 7:59:14 PM UTC+5:30, Chris Angelico wrote:
> The similarities and differences between the variable models are no
> more relevant. What becomes relevant are the PyObject* pointer (the C
> interface to a Python object (not variable)) and the various functions
> for manipulating namespaces, mainly dictionaries. If anything, you
> need to be more aware that Python and C variables are completely
> different beasts. CPython's C API [1] is fairly manual; you INCREF and
> DECREF objects, there's no concept of "automatic variables", etc etc
> etc. 

On the contrary, you need to respect the C system to get past the C compiler.
And you need to uphold the expected python invariants to get code that works.

So the variables inside the C functions are (as always in C) automatic
But they dont become easily and naturally such in python

Hence all the INCREF/ownership etc headaches

IOW one needs to have both worlds under one's belt

Of course one can use swig or boost or ctype and replace one headache with other(s)



More information about the Python-list mailing list