
Yes, everyone, it is the moment you have all dreaded. A new version of pure python __builtin__s. This version contains nudity, sexual references, chr implemented using '%c'%i, an optimized ord, multiarg map and zip, and the new functions unichr, oct, hex, staticmethod, *attr (for * in (get,has,set)), isinstance, issubclass, and slice. I did not include classmethod as this seems to warrent further discussion. Stuff I think can be easily done in python that haven't been yet: dir, raw_input, reload, round, and xrange. thinks-python-can-be-faster-than-c-ly yours, -Scott -- char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r; r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c== '+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(1,p,1),c-','||read(2,p,1));}

[Scott Fenton Fri, Jan 24, 2003 at 08:25:23AM -0500]
Yes, everyone, it is the moment you have all dreaded. A new version of pure python __builtin__s. This version contains nudity, sexual references, chr implemented using '%c'%i, an optimized ord, multiarg map and zip, and the new functions unichr, oct, hex, staticmethod, *attr (for * in (get,has,set)), isinstance, issubclass, and slice. I did not include classmethod as this seems to warrent further discussion. Stuff I think can be easily done in python that haven't been yet: dir, raw_input, reload, round, and xrange.
aehm, did i miss anything or was your attachment lost?
thinks-python-can-be-faster-than-c-ly yours,
depends-on-what-you-measure-anyway-ly y'rs, holger

Oops. Sorry about that. The code, as before, is at http://fenton.balitmore.md.us/pypy.py On Sun, Jan 26, 2003 at 05:28:03PM +0100, holger krekel wrote:
[Scott Fenton Fri, Jan 24, 2003 at 08:25:23AM -0500]
Yes, everyone, it is the moment you have all dreaded. A new version of pure python __builtin__s. This version contains nudity, sexual references, chr implemented using '%c'%i, an optimized ord, multiarg map and zip, and the new functions unichr, oct, hex, staticmethod, *attr (for * in (get,has,set)), isinstance, issubclass, and slice. I did not include classmethod as this seems to warrent further discussion. Stuff I think can be easily done in python that haven't been yet: dir, raw_input, reload, round, and xrange.
aehm, did i miss anything or was your attachment lost?
thinks-python-can-be-faster-than-c-ly yours,
depends-on-what-you-measure-anyway-ly y'rs,
holger
-- char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r; r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c== '+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(1,p,1),c-','||read(2,p,1));}

[Scott Fenton Sun, Jan 26, 2003 at 11:33:52AM -0500]
Oops. Sorry about that. The code, as before, is at http://fenton.balitmore.md.us/pypy.py
can't reach it from here. But that's probably just me. Somehow i get a lot of DNS-resolve problems though i can access *some* sites just fine. I don't yet see the pattern. holger

At 18:19 2003-01-26 +0100, holger krekel wrote:
[Scott Fenton Sun, Jan 26, 2003 at 11:33:52AM -0500]
Oops. Sorry about that. The code, as before, is at http://fenton.balitmore.md.us/pypy.py ^^--transposed
typo: Baltimore is a us city ;-)
can't reach it from here. But that's probably just me. Somehow i get a lot of DNS-resolve problems though i can access *some* sites just fine. I don't yet see the pattern.
This just worked for me: http://fenton.baltimore.md.us/pypy.py Cheers, Bengt

Scott Fenton wrote:
Oops. Sorry about that. The code, as before, is at http://fenton.balitmore.md.us/pypy.py
http://fenton.baltimore.md.us/pypy.py Please, do us the favor and never type an URL in, but always browse to it and do a correct copy and paste. many thanks - chris

My apologies. I was in a rush to dash off the email, and my fingers slipped. -Scott On Mon, Jan 27, 2003 at 12:05:13AM +0100, Christian Tismer wrote:
Scott Fenton wrote:
Oops. Sorry about that. The code, as before, is at http://fenton.balitmore.md.us/pypy.py
http://fenton.baltimore.md.us/pypy.py
Please, do us the favor and never type an URL in, but always browse to it and do a correct copy and paste.
many thanks - chris
-- char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r; r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c== '+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(1,p,1),c-','||read(2,p,1));}

[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

On Mon, Jan 27, 2003 at 01:17:31AM +0100, holger krekel wrote:
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.
<sarcasm>Them thar's fightin' words, pardner</sarcasm>
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.
Don't worry. I'll take care of it. I just wanted to get a rough sketch out first
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
Or you do what I do and copy and paste them.
cheers,
holger
more cheers, -Scott -- char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r; r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c== '+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(1,p,1),c-','||read(2,p,1));}

[Scott Fenton Sun, Jan 26, 2003 at 07:24:06PM -0500]
On Mon, Jan 27, 2003 at 01:17:31AM +0100, holger krekel wrote:
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.
<sarcasm>Them thar's fightin' words, pardner</sarcasm>
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.
Don't worry. I'll take care of it. I just wanted to get a rough sketch out first
great. sorry if my posting sounded to harsh. holger

Scott Fenton <scott@fenton.baltimore.md.us> writes:
Stuff I think can be easily done in python that haven't been yet: dir, raw_input, reload, round, and xrange.
dir is probably possible but a bit tedious. raw_input is impossible if you what full compatibility AFAICT (readline). round, xrange, reload should all be pretty easy. Cheers, M.

On Mon, 27 Jan 2003 17:07:17 +0100, Michael Hudson wrote:
Scott Fenton <scott@fenton.baltimore.md.us> writes:
Stuff I think can be easily done in python that haven't been yet: dir, raw_input, reload, round, and xrange.
dir is probably possible but a bit tedious.
Don't know if this suits you, but some time ago I posted a dir version I rewrote dir based on C code to emulate 2.2 behaviour in 1.5.2. Didn't check if 'dir' code evolved since then. OTH, Pedro # new_dir.py """ Restranscript of python 2.2 dir() builtin. """ import types import sys def merge_class_dict(dict, aclass): classdict = getattr(aclass, "__dict__", None) if classdict is not None: dict.update(classdict) bases = getattr(aclass, "__bases__", None) if bases is not None: for base in bases: merge_class_dict(dict, base) def merge_list_attr(dict, obj, attrname): list = getattr(obj, attrname, None) if list is not None: for item in list: if type(item) is types.StringType: dict[item] = None def new_dir(obj=None): objType = type(obj) if obj is None: result = locals().keys() elif objType is types.ModuleType: result = obj.__dict__.keys() elif objType is types.ClassType or objType is types.TypeType: dict = {} merge_class_dict(dict, obj) result = dict.keys() else: dict = getattr(obj, "__dict__", None) if dict is None: dict = {} elif type(dict) is not types.DictType: dict = {} else: dict = dict.copy() merge_list_attr(dict, obj, "__members__") merge_list_attr(dict, obj, "__methods__") itsclass = getattr(obj, "__class__", None) if itsclass is not None: merge_class_dict(dict, itsclass) result = dict.keys() return result try: major, minor, micro, releaselevel, serial = sys.version_info if (major, minor) >= (2, 2): new_dir = dir except: pass
participants (6)
-
Bengt Richter
-
Christian Tismer
-
holger krekel
-
Michael Hudson
-
Pedro Rodriguez
-
Scott Fenton