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/028135.html below:

PEP 218 (sets); moving set.py to Lib

[Python-Dev] Re: PEP 218 (sets); moving set.py to Lib [Python-Dev] Re: PEP 218 (sets); moving set.py to LibTim Peters tim_one@email.msn.com
Wed, 21 Aug 2002 01:25:42 -0400
[Guido, retroactively channeling Tim]
> A few transformations down the road, here's a 4-line powerset() generator:
>
> def powerset(base):
>     pairs = [(2**i, x) for i, x in enumerate(base)]
>     for n in xrange(2**len(pairs)):
>         yield [x for m, x in pairs if m&n]

Mine used one less local variable, so is more cache-friendly <wink>.




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