How safe is modifying locals()?

Corey Coughlin corey.coughlin at
Mon Jul 28 23:57:51 CEST 2003

Interesting thread here, I'm enjoying reading this.  Of course, I know
next to nothing about Visual Basic, so I don't know if I can really
help all that much.  But it doesn't sound like implementing something
like pointers is that much trouble, just a matter of getting some
syntax you like.  Now if you were translating C into Python, I suspect
you might need a more complicated pointer model.  I mean, half the use
of pointers in C is to iterate down simple arrays, like strings, so
you'd have to make something more like this:

class CStack(object):
    def __init__():
	self.stack = []
	self.names = {}
    def malloc(sizeinbytes, object_name):
	self.names[object_name] = len(self.stack)
	for i in range(sizeinbytes):
    def pobj(pointer_index):
	return self.stack[pointer_index]
    def paddr(object_name):
	return self.names[object_name]

or something like that, obviously this isn't fleshed out, but given
the breathtakingly simple memory model of C, it should be a snap to
code up in Python.  Hmmm.... I wonder if the Python-In-Python people
are trying anything like this to convert the C library code for
CPython.  Or would it even be worth it?  I think I'll meditate on

More information about the Python-list mailing list