[C++-sig] boost.python: modifying class getattr

Hans Meine hans_meine at gmx.net
Tue Nov 15 18:33:28 CET 2005


On Tuesday 15 November 2005 01:59, Julien Sylvestre wrote:
> If I write:
> object Foo_ = class_<Foo>("Foo", init< >())
>       .def("__getattr__", &Foo::Foo_getattr)
>       .def("__setattr__", &Foo::Foo_setattr)
> ...,
>
> is there a way to modify the type object associated with Foo_ instances
> so that instead of calling PyObject_GenericGetAttr when an attribute is
> requested, Python calls a function
> PyObject *Foo_GetAttr(PyObject *obj, PyObject *name)

Ah, that would be cool; <dreaming>I would be looking for an analogous way to 
speed up __getitem__ making it comparable to that of a Python 
list..</dreaming>

Ciao, /  /
     /--/
    /  / ANS



More information about the Cplusplus-sig mailing list