Re: [Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
erators > might be infinitely long... you cannot ask for every "A" that might > eventually occur in an infinite sequence of letters. > > On Sat, Jun 10, 2017 at 10:08 PM, Neal Fultz wrote: > >> Agreed to a degree about providing it as code, but it may also be worth &g

Re: [Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
Agreed to a degree about providing it as code, but it may also be worth mentioning also that zlib itself implements rle [1], and if there was ever a desire to go "python all the way down" you need an RLE somewhere anyway :) That said, I'll be pretty happy with anything that replaces an hour of go

Re: [Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
I would also submit there's some value in the obvious readability of z = runlength.encode(sequence) vs z = [(k, len(list(g))) for k, g in itertools.groupby(sequence)] but that's my personal opinion. Everyone is welcome to use my code, but I probably won't submit to pypi for a two function mo

Re: [Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
Whoops, scratch that part about encode /decode. On Sat, Jun 10, 2017 at 8:33 PM, Neal Fultz wrote: > Yes, I mean zip compression :) > > Also, everyone's been posting decode functions, but encode is a bit harder > :). > > I think it should be equally easy to go one

Re: [Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
(l[0],len(l)) for g in groupby(it) for l in [list(g[1])]) >>>> >>>> Since "not every one line function needs to be in the standard library" >>>> is a guiding principle of Python, and even moreso of `itertools`, probably >>>> this is a recipe i

Re: [Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
f Python, and even moreso of `itertools`, probably > this is a recipe in the documentation at most. Or maybe it would have a > home in `more_itertools`. > > > On Sat, Jun 10, 2017 at 7:20 PM, Neal Fultz wrote: > >> Hello python-ideas, >> >> I am very new to

[Python-ideas] Run length encoding

2017-06-10 Thread Neal Fultz
Hello python-ideas, I am very new to this, but on a different forum and after a couple conversations, I really wished Python came with run-length encoding built-in; after all, it ships with zip, which is much more complicated :) The general idea is to be able to go back and forth between two rep