[pypy-dev] __builtin__ module

Armin Rigo arigo at tunes.org
Thu Jan 23 10:41:19 CET 2003


Hello Bengt,

On

    def chr(i):
        return "\x00\x01\x02x03...\xFF"[i]

versus

    def chr(i):
        return'%c' % i

I feel the second solution to be more to the point.  The first one seems 
redundant somehow: "pick the ith character from this string whose ith 
character just happen to have ASCII code i".  But that's probably a minor 
point.  It shows that chr() may well be implemented in pure Python using lower 
"primitives" (let's call them built-in functions or methods).

It may indeed be a good idea to draw a fluctuating but documented dependency
graph between pure Python and built-in functions.  It would let two teams work
on these two halves of the work: (1) writing pure Python functions (as Scott
did), and (2) writing built-in functions.

I think that Scott's work drew the line for the built-in functions.  Most of 
what he couldn't code must be done as built-in functions.


Armin.


More information about the Pypy-dev mailing list