Re: get each pair from a string.

2012-10-24 Thread Mark Lawrence
On 24/10/2012 10:32, wxjmfa...@gmail.com wrote: Le mardi 23 octobre 2012 18:41:45 UTC+2, Ian a écrit : On Tue, Oct 23, 2012 at 12:47 AM, wrote: In any case, have you been following the progress of issue 16061? There is a patch for the str.replace regression that you identified, which resu

Re: get each pair from a string.

2012-10-24 Thread wxjmfauth
Le mardi 23 octobre 2012 18:41:45 UTC+2, Ian a écrit : > On Tue, Oct 23, 2012 at 12:47 AM, wrote: > > > > In any case, have you been following the progress of issue 16061? > > There is a patch for the str.replace regression that you identified, > > which results in better performance across

Re: get each pair from a string.

2012-10-23 Thread Ian Kelly
On Tue, Oct 23, 2012 at 12:47 AM, wrote: > The latest Python version is systematically slower > than the previous ones as soon as one uses non "ascii > strings". No, it isn't. You've previously demonstrated a *microbenchmark* where 3.3 is slower than 3.2. This is a far cry from demonstrating t

Re: get each pair from a string.

2012-10-23 Thread Mark Lawrence
On 23/10/2012 07:47, wxjmfa...@gmail.com wrote: Why bother with speeed? The latest Python version is systematically slower than the previous ones as soon as one uses non "ascii strings". Python users are discussing "code optimizations" without realizing the tool they are using, has killed itse

Re: get each pair from a string.

2012-10-23 Thread Neil Cerutti
On 2012-10-23, wxjmfa...@gmail.com wrote: > Why bother with speeed? Because the differences between O(N), O(log(N)) and O(N ** 2) operations are often relevant. A Python string replace function experiencing a slow-down from previous versions doesn't absolve me from making informed choices of alg

Re: get each pair from a string.

2012-10-22 Thread wxjmfauth
Le mardi 23 octobre 2012 06:59:49 UTC+2, rusi a écrit : > On Oct 22, 9:19 pm, rusi wrote: > > > On 10/21/2012 11:33 AM, Vincent Davis wrote: > > > > > > > I am looking for a good way to get every pair from a string. For example, > > > > input: > > > > x = 'apple' > > > > output > > > > 'ap'

Re: get each pair from a string.

2012-10-22 Thread rusi
On Oct 22, 9:19 pm, rusi wrote: > On 10/21/2012 11:33 AM, Vincent Davis wrote: > > > I am looking for a good way to get every pair from a string. For example, > > input: > > x = 'apple' > > output > > 'ap' > > 'pp' > > 'pl' > > 'le' > > Maybe zip before izip for a noob? > > >>> s="apple" > >>> [a+

Re: get each pair from a string.

2012-10-22 Thread Daniel Nogues
"apple" ... [s[i:i+2] for i in range(len(s)-1)]""",number=1) 0.0467379093170166 Regards From: rusi Date: 22 October 2012 17:19:35 IST To: python-list@python.org Subject: Re: get each pair from a string. On 10/21/2012 11:33 AM, Vincent Davis wrote: I am looking

Re: get each pair from a string.

2012-10-22 Thread rusi
On 10/21/2012 11:33 AM, Vincent Davis wrote: > I am looking for a good way to get every pair from a string. For example, > input: > x = 'apple' > output > 'ap' > 'pp' > 'pl' > 'le' Maybe zip before izip for a noob? >>> s="apple" >>> [a+b for a,b in zip(s, s[1:])] ['ap', 'pp', 'pl', 'le'] >>> --

Re: get each pair from a string.

2012-10-22 Thread Emile van Sebille
On 10/21/2012 9:19 PM, Ian Foote wrote: On 22/10/12 09:03, Emile van Sebille wrote: So, as OP's a self confessed newbie asking about slicing, why provide an example requiring knowledge of tee, enumerate, next and izip? Because not only the newbie will read the thread? I for one was interested

Re: get each pair from a string.

2012-10-21 Thread Ian Foote
On 22/10/12 09:03, Emile van Sebille wrote: So, as OP's a self confessed newbie asking about slicing, why provide an example requiring knowledge of tee, enumerate, next and izip? Because not only the newbie will read the thread? I for one was interested to see all the different possible appro

Re: get each pair from a string.

2012-10-21 Thread Vincent Davis
To All, I appreciate the range of answers and the time each of you take to think about and answer my question. Whether or not I use them I find them all educational. Thanks again. Vincent On Mon, Oct 22, 2012 at 2:03 AM, Emile van Sebille wrote: > On 10/21/2012 12:06 PM, Ian Kelly wrote: > >>

Re: get each pair from a string.

2012-10-21 Thread Vincent Davis
@vbr Thats interesting. I would never have come up with that. Vincent On Sun, Oct 21, 2012 at 3:48 PM, Vlastimil Brom wrote: > vbr -- http://mail.python.org/mailman/listinfo/python-list

Re: get each pair from a string.

2012-10-21 Thread Vlastimil Brom
2012/10/21 Vincent Davis : > I am looking for a good way to get every pair from a string. For example, > input: > x = 'apple' > output > 'ap' > 'pp' > 'pl' > 'le' > > I am not seeing a obvious way to do this without multiple for loops, but > maybe there is not :-) > In the end I am going to what to

Re: get each pair from a string.

2012-10-21 Thread Joshua Landau
On 21 October 2012 19:33, Vincent Davis wrote: > I am looking for a good way to get every pair from a string. For example, > input: > x = 'apple' > output > 'ap' > 'pp' > 'pl' > 'le' > > I am not seeing a obvious way to do this without multiple for loops, but > maybe there is not :-) > In the end

Re: get each pair from a string.

2012-10-21 Thread Emile van Sebille
On 10/21/2012 12:06 PM, Ian Kelly wrote: On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis wrote: x = 'apple' for f in range(len(x)-1): print(x[f:f+2]) @Ian, Thanks for that I was just looking in to that. I wonder which is faster I have a large set of strings to process. I'll try some timin

Re: get each pair from a string.

2012-10-21 Thread Ian Kelly
On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis wrote: > x = 'apple' > for f in range(len(x)-1): > print(x[f:f+2]) > > @Ian, > Thanks for that I was just looking in to that. I wonder which is faster I > have a large set of strings to process. I'll try some timings if I get a > chance later tod

Re: get each pair from a string.

2012-10-21 Thread Emile van Sebille
On 10/21/2012 11:51 AM, Ian Kelly wrote: On Sun, Oct 21, 2012 at 12:33 PM, Vincent Davis wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe

Re: get each pair from a string.

2012-10-21 Thread Mark Lawrence
On 21/10/2012 19:33, Vincent Davis wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get t

Re: get each pair from a string.

2012-10-21 Thread Vincent Davis
@Emile, I feel a little stupid, in my mind it was more difficult than in reality. x = 'apple' for f in range(len(x)-1): print(x[f:f+2]) @Ian, Thanks for that I was just looking in to that. I wonder which is faster I have a large set of strings to process. I'll try some timings if I get a chan

Re: get each pair from a string.

2012-10-21 Thread Ian Kelly
On Sun, Oct 21, 2012 at 12:33 PM, Vincent Davis wrote: > I am looking for a good way to get every pair from a string. For example, > input: > x = 'apple' > output > 'ap' > 'pp' > 'pl' > 'le' > > I am not seeing a obvious way to do this without multiple for loops, but > maybe there is not :-) Use

Re: get each pair from a string.

2012-10-21 Thread Emile van Sebille
On 10/21/2012 11:33 AM, Vincent Davis wrote: I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to ge

get each pair from a string.

2012-10-21 Thread Vincent Davis
I am looking for a good way to get every pair from a string. For example, input: x = 'apple' output 'ap' 'pp' 'pl' 'le' I am not seeing a obvious way to do this without multiple for loops, but maybe there is not :-) In the end I am going to what to get triples, quads... also. Thanks Vincent -