Re: Making the case for repeat

2009-06-13 Thread K4NTICO
On 13 juin, 14:15, Steven D'Aprano wrote: > Boris Borcic wrote: > > This reminds me of an early programming experience that left me with a > > fascination. At a time where code had to fit in a couple dozens kilobytes, > > I once had to make significant room in what was already very tight and > > t

Re: Making the case for repeat

2009-06-13 Thread Steven D'Aprano
Boris Borcic wrote: > This reminds me of an early programming experience that left me with a > fascination. At a time where code had to fit in a couple dozens kilobytes, > I once had to make significant room in what was already very tight and > terse code. Code factoring *did* provide the room in

Re: Making the case for repeat

2009-06-12 Thread Boris Borcic
Raymond Hettinger wrote: There is a natural inclination to do the opposite. We factor code to eliminate redundancy, but that is not always a good idea with an API. The goal for code factoring is to minimize redundancy. The goal for API design is having simple parts that are easily learned and c

Re: Making the case for repeat

2009-06-09 Thread alex23
Steven D'Aprano wrote: > e.g. the Wright Brothers weren't lone inventors working at a time when > everyone knew powered flight was impossible, they were experienced > engineers and glider-pilots who paid a lot of attention to research done > by their many competitors. Be careful, the idea that hum

Re: Making the case for repeat

2009-06-08 Thread jkn
> Possibly a *factoring*, without the "re-", just like Raymond said. > > Also, keep in mind that when creating a new API, you have no existing API > to re-factor. Exactly. I think this has come up before, but I can't remember the answers; any suggestions for pointer to examples of very well-desi

Re: Making the case for repeat

2009-06-08 Thread Steven D'Aprano
On Mon, 08 Jun 2009 18:30:37 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> On Sun, 07 Jun 2009 16:46:23 -0700, Raymond Hettinger wrote: >> >> > We factor code to eliminate redundancy, but that is not always a good >> > idea with an API. The goal for code factoring is to minimize >> >

Re: Making the case for repeat

2009-06-08 Thread jkn
On Jun 8, 9:30 am, Ben Finney wrote: [...] > > As originally defined by Martin Fowler, re-factoring always means the > external behaviour is unchanged http://refactoring.com/>. > > So, there's no such thing as a re-factoring that changes the API. > Anything that changes an external attribute of t

Re: Making the case for repeat

2009-06-08 Thread Ben Finney
Steven D'Aprano writes: > On Sun, 07 Jun 2009 16:46:23 -0700, Raymond Hettinger wrote: > > > We factor code to eliminate redundancy, but that is not always a > > good idea with an API. The goal for code factoring is to minimize > > redundancy. The goal for API design is having simple parts that

Re: Making the case for repeat

2009-06-08 Thread Steven D'Aprano
On Sun, 07 Jun 2009 16:46:23 -0700, Raymond Hettinger wrote: > We factor code > to eliminate redundancy, but that is not always a good idea with an API. > The goal for code factoring is to minimize redundancy. The goal for API > design is having simple parts that are easily learned and can be rea

Re: Making the case for repeat

2009-06-07 Thread Raymond Hettinger
[pataphor] > So here is my proposed suggestion for a once and for all reconciliation > of various functions in itertools that can not stand on their own and > keep a straight face. Interesting phraseology ;-) Enticing and yet fallacious in its presumption of known and accepted usability problems.

Re: Making the case for repeat

2009-06-07 Thread bearophileHUGS
pataphor: > The problem is posting *this* > function would kill my earlier repeat for sure. And it already had a > problem with parameters < 0 (Hint: that last bug has now become a > feature in the unpostable repeat implementation) Be bold, kill your precedent ideas, and post the Unpostable :-) De

Re: Making the case for repeat

2009-06-06 Thread Steven D'Aprano
On Sat, 06 Jun 2009 19:32:31 -0700, Tim Roberts wrote: > Steven D'Aprano wrote: >> >>Why is it that it's (almost) always newbies with about five minutes' >>worth of experience with Python that come up with these grandiose plans >>to replace entire modules with a single function? > > Well, many g

Re: Making the case for repeat

2009-06-06 Thread Terry Reedy
Tim Roberts wrote: Steven D'Aprano wrote: Why is it that it's (almost) always newbies with about five minutes' worth of experience with Python that come up with these grandiose plans to replace entire modules with a single function? Well, many great innovations in history have come from peop

Re: Making the case for repeat

2009-06-06 Thread Tim Roberts
Steven D'Aprano wrote: > >Why is it that it's (almost) always newbies with about five minutes' >worth of experience with Python that come up with these grandiose plans >to replace entire modules with a single function? Well, many great innovations in history have come from people who did not ha

Re: Making the case for repeat

2009-06-05 Thread Carl Banks
On Jun 4, 6:44 pm, "Gabriel Genellina" wrote: > En Thu, 04 Jun 2009 10:37:45 -0300, pataphor escribió: > > > So here is my proposed suggestion for a once and for all reconciliation > > of various functions in itertools that can not stand on their own and > > keep a straight face. Because of backw

Re: Making the case for repeat

2009-06-05 Thread Steven D'Aprano
On Fri, 05 Jun 2009 23:21:40 -0300, Gabriel Genellina wrote: > En Fri, 05 Jun 2009 08:04:37 -0300, pataphor > escribió: > >> But what is simple? I am currently working on a universal feature >> creeper that could replace itertools.cycle, itertools.repeat, >> itertools.chain and reverse and also

Re: Making the case for repeat

2009-06-05 Thread Gabriel Genellina
En Fri, 05 Jun 2009 08:04:37 -0300, pataphor escribió: But what is simple? I am currently working on a universal feature creeper that could replace itertools.cycle, itertools.repeat, itertools.chain and reverse and also helps to severely cut down on itertools.islice usage. All within virtually

Re: Making the case for repeat

2009-06-05 Thread pataphor
Gabriel Genellina wrote: > Ok, you're proposing a "bidimensional" repeat. I prefer to keep things > simple, and I'd implement it in two steps. But what is simple? I am currently working on a universal feature creeper that could replace itertools.cycle, itertools.repeat, itertools.chain and rever

Re: Making the case for repeat

2009-06-04 Thread Gabriel Genellina
En Thu, 04 Jun 2009 10:37:45 -0300, pataphor escribió: So here is my proposed suggestion for a once and for all reconciliation of various functions in itertools that can not stand on their own and keep a straight face. Because of backwards compatibility issues we cannot remove them but we can b

Re: Making the case for repeat

2009-06-04 Thread pataphor
Steven D'Aprano wrote: > I've run your test code, and I don't know what I'm supposed to be > impressed by. Thank you for trying out the code. That you're unimpressed actually is a huge encouragement because code should just run the way people expect, without unnecessary surprises. P. -- http:/

Re: Making the case for repeat

2009-06-04 Thread Steven D'Aprano
On Thu, 04 Jun 2009 13:37:45 +, pataphor wrote: > This probably has a snowballs change in hell of ending up in builtins or > even some in some module, but such things should not prevent one to try > and present the arguments for what one thinks is right. Else one would > end up with consequent

Making the case for repeat

2009-06-04 Thread pataphor
): yield x def test(): #making the case for repeat from itertools import islice, cycle times = 2 n = 3 cycles = 2 L = range(n) #look ma, no islice! print list(repeat(L, cycles)) print list(repeat(L, cycles, times)) #repeat without extra