[Python-Dev] New builtins

M.-A. Lemburg mal@lemburg.com
Wed, 12 Jul 2000 12:18:03 +0200


Paul Prescod wrote:
> 
> "M.-A. Lemburg" wrote:
> >
> > ...
> >
> > Just for completeness: mx.Tools already has these APIs:
> >
> >      tuples(sequence)
> >          Returns much the same as apply(map,(None,)+tuple(sequence)) does,
> 
> Like it.
> 
> >      lists(sequence)
> >          Same as tuples(sequence), except that a tuple of lists is returned.
> 
> Like it.
> 
> >      dict(items)
> >          Constructs a dictionary from the given items sequence.
> 
> Like it.
> 
> In my opinion, these are naturals for built-in functions. Cool!
> 
> These I'm not as sure about:
> 
> >      irange(object[,indices])
> >          Builds a tuple of tuples (index,object[index]).
> 
> Isn't this just tuples( indices( object ), object )

Yep, but less to write...
 
> >      indices(object)
> >          Returns the same as tuple(range(len(object))) --
> 
> Could be obsoleted by the range-building syntax:
> 
> [0..len(object)]
> 
> would do the same thing.

True, except that I find indices(obj) more intuitive (and
its just one function call).

Technical note: tuples build faster than lists.
 
-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/