On Sat, May 10, 2014 at 8:34 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: > Right, Python's variables aren't like variables in C. Rather, Python's > variables are like CPU registers. They cannot hold typed or structured > objects and you can't pass references to them.
Are you thinking that a Python variable is neither more nor less than what CPython implements them as? Because I can design you a 100% compliant Python implementation in which: * Objects are represented with pieces of paper * Object types are represented with 150GSM paper so it's easier to find (note that an object type, being itself an object, must be represented with paper) * Named attributes and numeric indices (__[gs]etitem__) are recorded with ink on the paper * References, including from an object to its type, are pieces of string linking an attribute to another object * None is, in the interests of performance, represented by a piece of string that dangles * Functions get compiled down to a byte-code stored on eighty-column punched card * Integers and strings are always interned * The image processing library is stored inside an actual pillowcase * The 'print' function results in a human being speaking, and 'input' waits for another human to speak, and constructs a string with what was said As far as I know, this could be done, and it would be perfectly compliant with all of Python. It'd be horrendously slow, but Python's specs never demand performance. It wouldn't have C-like variables, it wouldn't have pointers (assigning "a = b" means looking up b, finding which object the string connects to, gluing another string to that same object, and severing any previous connection from a), and it certainly wouldn't have 32-bit or 64-bit integers, or anything like that. (Not that CPython has anything of the sort, as of 3.0, but it's perfectly conceivable for a compliant Python to have an optimization whereby "small" integers are handled more efficiently. Again, the Python specs don't say either way.) So what is a "variable" in this Python? Well... exactly what it is in any other Python, because this is just as much Python as CPython, Jython, PyPy, or any other. ChrisA -- https://mail.python.org/mailman/listinfo/python-list