Representation of new-style instance

Raj B rajb at rice.edu
Wed Aug 1 19:14:06 EDT 2007


Consider a new-style class

class rabbit(object):
       def __init__(self,c):
            self.color = c

r1=rabbit("blue")
r2=rabbit("purple")

Which C struct in the Python implementation is used to represent the  
instances c1 and c2 of the
new-style class? I understand that when the class 'rabbit' is  
created, the type_new function
in typeobject.c creates a copy of a 'struct typeobject' with  
dictionary tp_dict appropriately modified.

However, I can't figure out which structure is used for new-style  
instances and where the instance dictionary is stored. Could anyone  
please clarify?

Thanks
Raj



More information about the Python-list mailing list