Re: [Python-3000] Method descriptors

2007-12-12 Thread Guido van Rossum
On Dec 12, 2007 3:06 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > On Dec 12, 2007 2:45 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > > > >>Can you give me a link to that? I wasn't following the > >>discussion that closely. > > > > http://svn.python.org/view?rev=59469&view=r

Re: [Python-3000] Method descriptors

2007-12-12 Thread Greg Ewing
Guido van Rossum wrote: > On Dec 12, 2007 2:45 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > >>Can you give me a link to that? I wasn't following the >>discussion that closely. > > http://svn.python.org/view?rev=59469&view=rev That's not quite what I had in mind -- Pyrex already solves the problem

Re: [Python-3000] Method descriptors

2007-12-12 Thread Marcin ‘Qrczak’ Kowalczyk
Dnia 12-12-2007, Śr o godzinie 15:10 +1300, Greg Ewing pisze: > > > CFunction does not define descr_get - why? > > > > I don't see why we should bother. > > I put forward a possible reason recently -- so that > Pyrex-defined functions could be used as methods > without requiring any special tric

Re: [Python-3000] Method descriptors

2007-12-12 Thread Guido van Rossum
On Dec 12, 2007 2:45 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > On Dec 11, 2007 6:10 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > > > >>I put forward a possible reason recently -- so that > >>Pyrex-defined functions could be used as methods > >>without requiring any spec

Re: [Python-3000] Method descriptors

2007-12-12 Thread Greg Ewing
Guido van Rossum wrote: > On Dec 11, 2007 6:10 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > >>I put forward a possible reason recently -- so that >>Pyrex-defined functions could be used as methods >>without requiring any special trickery. > > > Would the new API that Christian just checked in hel

Re: [Python-3000] Method descriptors

2007-12-12 Thread Christian Heimes
Greg Ewing wrote: > I put forward a possible reason recently -- so that > Pyrex-defined functions could be used as methods > without requiring any special trickery. http://svn.python.org/view?rev=59469&view=rev PyObject *wrapped = PyInstanceMethod_New(PyObject *callable); The API isn't exposed t

Re: [Python-3000] Method descriptors

2007-12-11 Thread Guido van Rossum
On Dec 11, 2007 6:10 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > On Dec 11, 2007 1:50 AM, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> > > wrote: > > > > > CFunction does not define descr_get - why? > > > > I don't see why we should bother. > > I put forward a possible

Re: [Python-3000] Method descriptors

2007-12-11 Thread Greg Ewing
Guido van Rossum wrote: > On Dec 11, 2007 1:50 AM, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > > > CFunction does not define descr_get - why? > > I don't see why we should bother. I put forward a possible reason recently -- so that Pyrex-defined functions could be used as methods with

Re: [Python-3000] Method descriptors

2007-12-11 Thread Guido van Rossum
On Dec 11, 2007 1:50 AM, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > I'm not convinced that Python on its own needs it. Perhaps Python > already distinguishes function-like objects from others rigorously > enough that they should care about being descriptors themselves. Right. The use c

Re: [Python-3000] Method descriptors

2007-12-11 Thread Christian Heimes
Marcin ‘Qrczak’ Kowalczyk wrote: > Below is what I have, after some cleaning and renaming. Needs more > cleaning to plug it into Python modules and conform to Python coding > standards. http://bugs.python.org/issue1587 I've added \t to the formatting, changed the name slightly and filled a bunch o

Re: [Python-3000] Method descriptors

2007-12-11 Thread Marcin ‘Qrczak’ Kowalczyk
Dnia 11-12-2007, Wt o godzinie 01:32 +0100, Christian Heimes pisze: > Marcin, can you come up with a patch? Below is what I have, after some cleaning and renaming. Needs more cleaning to plug it into Python modules and conform to Python coding standards. I'm not convinced that Python on its own

Re: [Python-3000] Method descriptors

2007-12-10 Thread Christian Heimes
Guido van Rossum wrote: > I guess there's no such egneric wrapper in the core because the use > case hasn't presented itself before -- or nobody thought of creating a > generic solution. > > It's also possible that in the past this was done using unbound > methods -- so perhaps their removal from

Re: [Python-3000] Method descriptors

2007-12-10 Thread Guido van Rossum
On Dec 10, 2007 2:57 PM, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > Dnia 10-12-2007, Pn o godzinie 11:01 -0800, Guido van Rossum pisze: > > > Add a __get__ (instance) method to f's class, and store f directly in > > A. Your __get__ method should return a bound object using > > PyMethod_

Re: [Python-3000] Method descriptors

2007-12-10 Thread Marcin ‘Qrczak’ Kowalczyk
Dnia 10-12-2007, Pn o godzinie 11:01 -0800, Guido van Rossum pisze: > Add a __get__ (instance) method to f's class, and store f directly in > A. Your __get__ method should return a bound object using > PyMethod_New(f, a). Thank you, but I can't do this, because I want a generic mechanism which wo

Re: [Python-3000] Method descriptors

2007-12-10 Thread Guido van Rossum
On Dec 8, 2007 9:45 AM, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > I'm confused about storing methods in class dictionaries from the point > of view of the C API. > > 1. Let's say that I have a callable PyObject called f, of my type >defined in C. I want to store something derived f

Re: [Python-3000] Method descriptors

2007-12-08 Thread Christian Heimes
Marcin ‘Qrczak’ Kowalczyk wrote: >BTW, applying PyMethod_Type to 3 arguments crashes Python3. I think >this line is the culprit (classobject.c): > > if (!PyArg_UnpackTuple(args, "method", 2, 3, > &func, &self)) > >Should be 2 instead of 3. There u

[Python-3000] Method descriptors

2007-12-08 Thread Marcin ‘Qrczak’ Kowalczyk
I'm confused about storing methods in class dictionaries from the point of view of the C API. 1. Let's say that I have a callable PyObject called f, of my type defined in C. I want to store something derived from f as A.m for some class A, such that for an object a of class A, calling a.m