[pypy-dev] Builtin-in functions

Armin Rigo arigo at tunes.org
Tue May 3 20:02:40 CEST 2005


Hi all,

Builtin-in functions differ from Python function in that you can't bind the
former as methods.  We are discovering more and more of cases like that:

class Stuff:
    defaultComparison = cmp

where self.defaultComparison(x,y) is expected to work.  Instead, in PyPy, cmp
is then called with three arguments: self, x, y.

The problem is the number of cases we keep finding all around.  I think that
Guido said it was an internal undefined detail, but clearly a lot of people
depend on it, so we're stuck.

Samuele came up with a nice proposal: the attribute loading code of LazyModule
(i.e. our internal modules) is a natural place to turn our functions into some
kind of built-in functions.  It will turn exactly the function into built-in
ones and leave alone, e.g., the methods of class complex -- which need to be
boundable to their complex instance!

The proposal is thus to wrap functions into a <type 'builtin_function'> which
behaves mostly like the original one, but doesn't have a __get__().


A bientot,

Armin



More information about the Pypy-dev mailing list