Can an object of a C type have random members added? tp_dictoffset?

Gregory Bond gnb at itga.com.au
Thu Apr 21 03:55:24 EDT 2005


One of the cool things about Python is the ability to "decorate" objects 
with random extra members:
	class C:
		def __init__(self):
			self.foo = 0
	c = C()
	c.bar = 1

I have a class implemented in C using tp_members to specify (read-only) 
access to data members in the C struct. I'd like to be able to do the 
decoration trick with objects of this class.  Is this possible?

[The documentation for tp_dictoffset eseems to hint that this is 
possible..... how do I use it?]



More information about the Python-list mailing list