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/2000-July/006287.html below:

[Python-Dev] re: list comprehension / pop quiz

[Python-Dev] re: list comprehension / pop quizMoshe Zadka Moshe Zadka <moshez@math.huji.ac.il>
Wed, 12 Jul 2000 20:26:34 +0300 (IDT)
On Wed, 12 Jul 2000 esr@thyrsus.com wrote:

> Presto! All need for parallel loops has now disappeared.  If anyone
> doubts this, I will cheerfully produce source code for with().

Ummm.....you mean

def with(*args):
	apply(map, (None,)+args)

;-)

(Actually, this isn't right, since map() adds None's instead of stopping.
But that should be a considered a design bug in map() anyway)

What would people think about xmap(), which acts anologously to xrange(),
IOW calculate lazilly instead of eagerly? Or even, calculate "on demand",
without caching:

class xmap:

	def __init__(self, func, *args):
		self.func = func
		self.args = args

	def __getitem__(self, i):
		arg = [None]*len(self.args)
		for j in range(len(self.args)):
			arg[j] = self.args[j][i]
		return apply(self.func, arg)

Wouldn't this solve the parallel iteration problem?
--
Moshe Zadka <moshez@math.huji.ac.il>
There is no GOD but Python, and HTTP is its prophet.
http://advogato.org/person/moshez




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