A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-June/004709.html below:

why doesn't list.extend use the sequence interface?

[Python-Dev] Q: why doesn't list.extend use the sequence interface?M.-A. Lemburg mal@lemburg.com
Sat, 17 Jun 2000 16:44:47 +0200
Fredrik Lundh wrote:
> 
> mal wrote:
> > The above looks a lot like an iterator... how about
> > providing a standard PySequence_Iterate(obj, callback)
> > with the callback being called for every element of the
> > sequence ?!
> 
> PySequence_Enumerate, perhaps?
>
> > The iterator could then be optimized for lists and tuples.
> > Not as fast as inlining, but a more generic solution...
> 
> more generic than useful, imo:
> 
>     - it's slower.
> 
>     - it's awkward to use: you need to put the state in a
>       structure, invert your program logic, etc.
> 
>     - it doesn't scale: what if you want to loop over two
>       structures?  what if you want to loop over two objects,
>       using two different indices?

Or perhaps, use a different iteration technique: the one
used by PyDict_Next(). It doesn't need a callback, but
instead plays with pointers you pass to it via output
variables.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4