itertools comments [Was: Re: RELEASED: Python 2.3a2]

Magnus Lie Hetland mlh at furu.idi.ntnu.no
Fri Feb 21 22:59:20 EST 2003


In article <SEc5a.464$Wo6.163 at nwrdny03.gnilink.net>, Raymond Hettinger wrote:
>> def xgroup(iter,n=2):
>>     r"""Iterate `n`-wise (default pairwise)  over `iter`.
[snip]
>> def xwindow(iter, n=2, s=1):
>>     r"""Move an `n`-item (default 2) windows `s` steps (default 1) at a
>time
>>     over `iter`.
>
>I've needed this one only one time in twenty-five years of programming
>(for the markov algorithm).  Again, solid use cases are needed.

I use this sort of thing a lot, when discretizing/processing time
series -- a sliding window is useful for many things there (e.g.
running averages). At the moment I'm using numarray for this stuff,
but wouldn't mind an iterator approach -- especially with some
standard library tools :)

-- 
Magnus Lie Hetland               "Nothing shocks me. I'm a scientist." 
http://hetland.org                                   -- Indiana Jones




More information about the Python-list mailing list