Casey Duncan wrote:
I think this is an important feature, which allows you to define
generic, reusable getter and setter functions and pass static metadata
to them at runtime. Admittedly I have never needed the full pointer,
my typical usage is to pass in an offset.
I think this should only be removed if a suitable mechanism replaces
it, if not it will require some needless duplication of code in
extensions that use it (in particular my own) 8^)
I disagree; I think it is a minor convenience feature, and one which
encourages a lack of type safety.
A suitable replacement mechanism already exists in C:
static PyObject *generic_getter(PyObject *o, int context) {
/* your generic code goes here */
}
static PyObject *getter_with_context_1(o) { return generic_getter(o,
1); }
static PyObject *getter_with_context_2(o) { return generic_getter(o,
2); }
static PyObject *getter_with_context_3(o) { return generic_getter(o,
3); }
You would then use "getter_with_context_1" &c in your PyGetSetDef. With
a clever optimizing compiler this should result in no detectable
slowdown or code bloat.
However, you will be happy to learn there wasn't much support for this
change, so it didn't make it into Python 3.1.
/larry/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com