A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-August/028384.html below:

[Python-Dev] A `cogen' module - an observation

[Python-Dev] A `cogen' module - an observationOren Tirosh oren-py-d@hishome.net
Wed, 28 Aug 2002 00:44:50 -0400
On Wed, Aug 28, 2002 at 12:40:30PM +1200, Greg Ewing wrote:
> Oren Tirosh <oren-py-d@hishome.net>:
> 
> > > Hmmm, in other words, cartesian() is a lazy version
> > > of zip().
> > 
> > Nope.
> > 
> > >>> zip([1, 2], ['a', 'b'])
> > [(1, 'a'), (2, 'b')]
> > 
> > >>> list(cartesian([1, 2], ['a', 'b']))
> > [(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b')]
> 
> Sorry, BrainError. In that case, it's probably
> faster to use the nested loops -- unless
> cartesian() were implemented in C.

Yes, but a nested loop cannot be easily passed as an argument to a 
function. Generator functions are pretty efficient, too - yield does 
not incur the relatively high overhead of Python function calls.

	Oren



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