[pypy-dev] New __builtin__

holger krekel hpk at trillke.net
Mon Jan 27 01:17:31 CET 2003


[Scott Fenton Sun, Jan 26, 2003 at 06:00:53PM -0500]
> My apologies. I was in a rush to dash off the
> email, and my fingers slipped. 

i tested your code with the Python-2.2.2 test_builtin.py
(found in Python-2.2.2/Lib/test, has some dependencies). 

1) your code does not import cleanly (some typos here
   and there)

2) the tests fail right at 'abs', the first builtin
   because you don't throw a TypeError if the argument
   is not a number.  

I take it that you didn't seriously intend your code 
to be used as is.  

Nevertheless, it would be nice to have a python 
implementation of the builtin module that passes 
its CPython's tests.  Also the docstrings should be
copied from Python-2.3.  This can be done automatically 
by writing a script and iterating over 
vars(__import__('__builtin__')) and using the inspect 
module.  I hopefully can do this soon and check it into
the upcoming repository.  Or somebody else does it before
me.  

Note, that you cannot automize extraction 
of signatures of the builtin callables in all cases.  
C-implemented builtins don't have signature-introspection 
methods but often have a conventional (and quite parseable)
description in the first line of the docstring, e.g.

    >>> print abs.__doc__
    abs(number) -> number

cheers,

    holger


More information about the Pypy-dev mailing list