unexpected behavior: did i create a pointer?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Fri Sep 7 06:40:47 EDT 2007


On Fri, 07 Sep 2007 11:46:38 +0200, Wildemar Wildenburger wrote:

> gu wrote:
>> hi to all!
>> after two days debugging my code, i've come to the point that the
>> problem was caused by an unexpected behaviour of python. or by lack of
>> some information about the program, of course! i've stripped down the
>> code to reproduce the problem:
>> 
>> [snip FAQ]
> 
> Yes, basically you *created* a pointer. That's all that python has:
> pointers.

No, you are confusing the underlying C implementation with Python. Python 
doesn't have any pointers. CPython is implemented with pointers. PyPy, 
being written entirely in Python, is implemented with Python objects like 
lists and dicts. Jython, being implemented in Java, probably isn't 
implemented with pointers either -- although of course the underlying 
Java compiler might be. IronPython and Python for .Net, I have no idea 
how they work. Could be magic for all I know. (Probably necromancy.) 

Naturally, regardless of whether you are using CPython, IronPython, PyPy 
or some other variety of Python, the objects available to you include 
ints, floats, strings, lists, dicts, sets and classes... but not pointers.

Nor does it include "peek" and "poke" commands for reading and writing 
into random memory locations. Python is not C, and it is not Basic, nor 
is it Forth or Lisp or assembler, and you shouldn't hammer the round peg 
of Python objects into the square hole of C pointers.



-- 
Steven.



More information about the Python-list mailing list