[Python-Dev] Python memory model (low level)
"Martin v. Löwis"
martin at v.loewis.de
Fri Jun 30 22:30:47 CEST 2006
More information about the Python-Dev mailing list
Fri Jun 30 22:30:47 CEST 2006
- Previous message: [Python-Dev] Python memory model (low level)
- Next message: [Python-Dev] Python memory model (low level)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters wrote: > Don't know what "raw data" might mean here. Any Python object can be > bound to any attribute of a class. In Python, e.g., > > class MyClass: > > mydata = ['xyz', 12] > > def method(self): > MyClass.mydata.append(-1) > # or, more inheritance-friendly > self.__class__.mydata.append(-1) > > This is substantially more long-winded in C. To get a starting point: PyDict_GetItemString(MyClass->tp_dict, "mydata") is the equivalent of self.__class__.mydata That way, the raw data would get exposed to the Python level. If you don't want this to happen, you could also revert the lookup: static PyObject *mydata; /* = PyDict_New() */ and then PyDict_GetItem(mydata, MyClass) If "raw" means "non-PyObject", you would have to wrap the raw data pointer with a CObject first. Regards, Martin
- Previous message: [Python-Dev] Python memory model (low level)
- Next message: [Python-Dev] Python memory model (low level)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list