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

Greg Ewing greg@cosc.canterbury.ac.nz
Wed, 28 Aug 2002 12:40:30 +1200 (NZST)


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.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+