My own 12 points list

Andrew Dalke adalke at mindspring.com
Tue Aug 26 13:13:16 EDT 2003


nnes:
> 4.) Eliminate xrange(), replace range() with xrange() implementation

There might be some code which breaks, eg., how would
you handle

>>> a = range(10)
>>> a.sort()
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a = xrange(10)
>>> a.sort()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'xrange' object has no attribute 'sort'
>>>

Not impossible.  Would need some behind the scenes switching,
eg "if I'm a virtualized list and sort/append/... is called then make
me real before finishing those calls.  This then makes the
memory behaviour a bit unexpected, because

a = range(sys.maxint)
 ...

a[0] = a[0]

causes the out-of-memory condition at the assignment line
and not the range line.

> 5.) Eliminate built-in functions buffer(), callable(), delattr(),
> dir(), getattr(), hasattr(), hash(), help(), id(), isinstance(),
> len(), max(), min(), repr(),  setattr(), sum(), str(), type(),
> unichr() and make them methods of the root or base object. Transform
> them into object.func(parameters).

That will definitely break old code like

class MyClass:
    def __init__(self, id):
        self.id = id

Some of these make no sense as part of the base object.
Eg, 'min' and 'max' only make sense when applied to iterables,
as in

>>> def f():
...      for i in range(10):
...           yield i
...
>>> min(f())
0
>>> max(f())
9
>>>

Personally, as I mentioned recently, I like having the special
methods needed by the language be written special so there's
no way I can accidentally redefine, say, 'hash'.

> 7.) Eliminate locals(), globals() and replace with a vars() that
> defaults to locals, and accept a parameter to get globals().

Well, locals() returns a read-only dict while globals() can
be modified.  What's wrong with having these as two different
functions?

> 10.) Eliminate the recursion limit on functions or better yet, include
> an option to change from the default to infinite. No need to change
> anything in the language. A lot of work in the implementation though.
> Could use regular method up to a number of calls and then switch to a
> less performant method.

Do you mean make Python be tail recursive or do you
mean set sys.setrecursionlimit to sys.maxint?  You can do the
latter yourself, only at some point you'll get a segmentation violation
when you reach the OS limits, and Python won't be able to
recover.

Mmmmm, I see.  You want to allocate from the heap instead of
the stack, like what Stackless does.

> 11.) Add a big decimal type (something like java) in the standard
> library. To be able to do bean counter type math easily. Are there so
> few python applications that deal with money?

There's a FixedPoint module available for this.  Search the
archives for the current status for why it hasn't been added yet.

Perhaps those who need is are like the engineers who need
matricies so install Numeric.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list