On Friday, February 14, 2014 1:01:48 PM UTC-8, Mark Lawrence wrote:
[snip]
>
> Pleased to have you on board, as I'm know that Terry Reedy et al can do
> with a helping hand.
>
> But please note you appear to be using google groups, hence the double
> line spacing above and trying to reply to pa
On 14/02/2014 20:04, forman.si...@gmail.com wrote:
On Thursday, February 13, 2014 7:26:48 PM UTC-8, Ned Batchelder wrote:
On 2/13/14 9:45 PM, forman.si...@gmail.com wrote:
For the record I wasn't worried about the performance. ;-)
It was for Tkinter event strings not markup tags.
On Thursday, February 13, 2014 7:26:48 PM UTC-8, Ned Batchelder wrote:
> On 2/13/14 9:45 PM, forman.si...@gmail.com wrote:
>
> > For the record I wasn't worried about the performance. ;-)
>
> >
>
> > It was for Tkinter event strings not markup tags.
>
> >
>
> > I'm glad this was the time winn
In article ,
Dave Angel wrote:
> Terry Reedy Wrote in message:
> > On 2/13/2014 1:37 PM, forman.si...@gmail.com wrote:
> >> I ran across this and I thought there must be a better way of doing it,
> >> but then after further consideration I wasn't so sure.
> >>
> >>if key[:1] + key[-1:] ==
Terry Reedy Wrote in message:
> On 2/13/2014 1:37 PM, forman.si...@gmail.com wrote:
>> I ran across this and I thought there must be a better way of doing it, but
>> then after further consideration I wasn't so sure.
>>
>>if key[:1] + key[-1:] == '<>': ...
>
> if key[:1] == '<' and key[-1:]
On 2/13/14 9:45 PM, forman.si...@gmail.com wrote:
For the record I wasn't worried about the performance. ;-)
It was for Tkinter event strings not markup tags.
I'm glad this was the time winner!
"key and key[0] == '<' and key[-1] == '>'"
Cheers to the folks who did the timings (and saved me
For the record I wasn't worried about the performance. ;-)
It was for Tkinter event strings not markup tags.
I'm glad this was the time winner!
"key and key[0] == '<' and key[-1] == '>'"
Cheers to the folks who did the timings (and saved me from the trouble!)
Last but not least... s[::len(s
On 02/13/2014 01:24 PM, Roy Smith wrote:
Emile van Sebille wrote:
But I didn't see this one:
s[::len(s)-1]
I love it. I need to add this to my list of Python trivia questions.
Great interview question: What does this do? What is its weakness? How would
you fix it?
--
~Ethan~
--
htt
On 2/13/2014 1:37 PM, forman.si...@gmail.com wrote:
I ran across this and I thought there must be a better way of doing it, but
then after further consideration I wasn't so sure.
if key[:1] + key[-1:] == '<>': ...
if key[:1] == '<' and key[-1:] == '>: ...
is the obvious choice to me. If th
On 02/13/2014 02:13 PM, Chris Angelico wrote:
On Fri, Feb 14, 2014 at 8:33 AM, Ethan Furman wrote:
Oh, it's not that bad! All you have to do is handle the edge case of an
empty string:
s[::len(s)-1 if s else True]
And the edge case of the one-character string.
Oops, my description should
On Fri, Feb 14, 2014 at 8:33 AM, Ethan Furman wrote:
> Oh, it's not that bad! All you have to do is handle the edge case of an
> empty string:
>
> s[::len(s)-1 if s else True]
>
> *ducks and runs*
And the edge case of the one-character string. Also, it's been noted
that calling the built-in func
On 02/13/2014 01:01 PM, Chris Angelico wrote:
On Fri, Feb 14, 2014 at 7:55 AM, Emile van Sebille wrote:
On 2/13/2014 11:59 AM, Zachary Ware wrote:
In a fit of curiosity, I did some timings:
Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :)
But I didn't see this one:
s[::le
In article ,
Serhiy Storchaka wrote:
> 13.02.14 21:59, Zachary Ware напиÑав(ла):
> > don't use re for simple stuff (because while it may be very fast, it's
> > dominated by attribute lookup and function call overhead),
>
> And the time of re variant depends on the size of input.
That'
13.02.14 21:59, Zachary Ware написав(ла):
don't use re for simple stuff (because while it may be very fast, it's
dominated by attribute lookup and function call overhead),
And the time of re variant depends on the size of input.
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, Feb 13, 2014 at 3:31 PM, Chris Angelico wrote:
> On Fri, Feb 14, 2014 at 8:19 AM, Zachary Ware
> wrote:
>> Also, uglier than sin itself.
>
> Hey hey, no need to insult our lovely trigonometric functions!
Here's your sine...
--
Zach
--
https://mail.python.org/mailman/listinfo/python-li
In article ,
Chris Angelico wrote:
> On Fri, Feb 14, 2014 at 8:19 AM, Zachary Ware
> wrote:
> > Also, uglier than sin itself.
>
> Hey hey, no need to insult our lovely trigonometric functions!
This newsgroup is taylor made for that kind of abuse.
--
https://mail.python.org/mailman/listinfo/p
On Fri, Feb 14, 2014 at 8:19 AM, Zachary Ware
wrote:
> Also, uglier than sin itself.
Hey hey, no need to insult our lovely trigonometric functions!
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
On 2/13/2014 1:10 PM, Chris Angelico wrote:
On Fri, Feb 14, 2014 at 8:06 AM, Peter Otten <__pete...@web.de> wrote:
For the record:
s = "x"
s[::len(s)-1]
Traceback (most recent call last):
File "", line 1, in
ValueError: slice step cannot be zero
And that, my friends, is a classic exampl
In article ,
Emile van Sebille wrote:
> On 2/13/2014 11:59 AM, Zachary Ware wrote:
> > In a fit of curiosity, I did some timings:
>
> Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :)
>
> But I didn't see this one:
>
> s[::len(s)-1]
>
> Emile
I love it. I need to add this to
On Thu, Feb 13, 2014 at 3:01 PM, Neil Cerutti wrote:
> On 2014-02-13, Zachary Ware wrote:
>> C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'"
>> Traceback (most recent call last):
>> File "P:\Python34\lib\timeit.py", line 292, in main
>> x = t.timeit(number)
>> File "P
On Thu, Feb 13, 2014 at 2:55 PM, Emile van Sebille wrote:
> On 2/13/2014 11:59 AM, Zachary Ware wrote:
>>
>> In a fit of curiosity, I did some timings:
>
>
> Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :)
>
> But I didn't see this one:
>
> s[::len(s)-1]
It's not great, around 0.
On 13/02/2014 21:01, Neil Cerutti wrote:
On 2014-02-13, Zachary Ware wrote:
In a fit of curiosity, I did some timings:
'and'ed indexing:
C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'"
100 loops, best of 3: 0.35 usec per loop
C:\tmp>py -m timeit -s "key = 'py -m time
On Fri, Feb 14, 2014 at 8:06 AM, Peter Otten <__pete...@web.de> wrote:
> For the record:
>
s = "x"
s[::len(s)-1]
> Traceback (most recent call last):
> File "", line 1, in
> ValueError: slice step cannot be zero
And that, my friends, is a classic example of a Python exception that
oug
Chris Angelico wrote:
> On Fri, Feb 14, 2014 at 7:55 AM, Emile van Sebille wrote:
>> On 2/13/2014 11:59 AM, Zachary Ware wrote:
>>>
>>> In a fit of curiosity, I did some timings:
>>
>>
>> Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :)
>>
>> But I didn't see this one:
>>
>> s[::l
On Fri, Feb 14, 2014 at 7:55 AM, Emile van Sebille wrote:
> On 2/13/2014 11:59 AM, Zachary Ware wrote:
>>
>> In a fit of curiosity, I did some timings:
>
>
> Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :)
>
> But I didn't see this one:
>
> s[::len(s)-1]
AAAR
On 2014-02-13, Zachary Ware wrote:
> In a fit of curiosity, I did some timings:
>
> 'and'ed indexing:
>
> C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'"
> 100 loops, best of 3: 0.35 usec per loop
>
> C:\tmp>py -m timeit -s "key = ' 100 loops, best of 3: 0.398 usec per
On 2/13/2014 11:59 AM, Zachary Ware wrote:
In a fit of curiosity, I did some timings:
Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :)
But I didn't see this one:
s[::len(s)-1]
Emile
--
https://mail.python.org/mailman/listinfo/python-list
On 2014-02-13 10:37, forman.si...@gmail.com wrote:
> I ran across this and I thought there must be a better way of doing
> it, but then after further consideration I wasn't so sure.
>
> Some possibilities that occurred to me:
>
> if key.startswith('<') and key.endswith('>'): ...
This is my fav
On Fri, Feb 14, 2014 at 6:32 AM, Mark Lawrence wrote:
>> There will be an exception only if it is zero-length. But good
>> point! That's a pretty sneaky way to avoid checking for a
>> zero-length string. Is it a popular idiom?
>>
>
> I hope not.
The use of slicing rather than indexing to avoid pr
On Thu, Feb 13, 2014 at 12:37 PM, wrote:
> I ran across this and I thought there must be a better way of doing it, but
> then after further consideration I wasn't so sure.
>
> if key[:1] + key[-1:] == '<>': ...
>
>
> Some possibilities that occurred to me:
>
> if key.startswith('<') and key.
Peter Otten <__pete...@web.de>:
> Personally, I'm willing to spend the few extra milliseconds and use
> the foolproof third.
Speaking of foolproof, what is this "key?" Is it an XML start tag,
maybe? Then, how does your test fare with, say,
which is equivalent to
Marko
--
https://m
On 02/13/2014 11:43 AM, Peter Otten wrote:
forman.si...@gmail.com wrote:
I ran across this and I thought there must be a better way of doing it,
but then after further consideration I wasn't so sure.
if key[:1] + key[-1:] == '<>': ...
Some possibilities that occurred to me:
if key.sta
On 2014-02-13, Peter Otten <__pete...@web.de> wrote:
> forman.si...@gmail.com wrote:
> The first is too clever for my taste.
>
> The second is fast and easy to understand. It might attract
> "improvements" replacing the slice with an index, but I trust
> you will catch that with your unit tests ;)
On 02/13/2014 11:17 AM, Neil Cerutti wrote:
On 2014-02-13, forman.si...@gmail.com
wrote:
I ran across this and I thought there must be a better way of
doing it, but then after further consideration I wasn't so
sure.
if key[:1] + key[-1:] == '<>': ...
Some possibilities that occurred to me:
forman.si...@gmail.com wrote:
> I ran across this and I thought there must be a better way of doing it,
> but then after further consideration I wasn't so sure.
>
> if key[:1] + key[-1:] == '<>': ...
>
>
> Some possibilities that occurred to me:
>
> if key.startswith('<') and key.endswith(
In article ,
Ethan Furman wrote:
> On 02/13/2014 11:09 AM, Mark Lawrence wrote:
> >
> > All I can say is that if you're worried about the speed of a single line of
> > code like the above then you've got
> > problems. Having said that, I suspect that using an index to extract a
> > single cha
On 13/02/2014 19:25, Neil Cerutti wrote:
On 2014-02-13, Ethan Furman wrote:
On 02/13/2014 11:09 AM, Mark Lawrence wrote:
All I can say is that if you're worried about the speed of a
single line of code like the above then you've got problems.
Having said that, I suspect that using an index to
On 2014-02-13, forman.si...@gmail.com
wrote:
> I ran across this and I thought there must be a better way of
> doing it, but then after further consideration I wasn't so
> sure.
>
> if key[:1] + key[-1:] == '<>': ...
>
> Some possibilities that occurred to me:
>
> if key.startswith('<') and ke
On 2014-02-13, Ethan Furman wrote:
> On 02/13/2014 11:09 AM, Mark Lawrence wrote:
>> All I can say is that if you're worried about the speed of a
>> single line of code like the above then you've got problems.
>> Having said that, I suspect that using an index to extract a
>> single character has
On 02/13/2014 11:20 AM, Ethan Furman wrote:
On 02/13/2014 11:09 AM, Mark Lawrence wrote:
All I can say is that if you're worried about the speed of a single
line of code like the above then you've got problems. Having said
that, I suspect that using an index to extract a single character
has
forman.si...@gmail.com writes:
> I ran across this and I thought there must be a better way of doing
> it, but then after further consideration I wasn't so sure.
>
> if key[:1] + key[-1:] == '<>': ...
>
> Some possibilities that occurred to me:
>
> if key.startswith('<') and key.endswith('>'):
On 02/13/2014 11:09 AM, Mark Lawrence wrote:
All I can say is that if you're worried about the speed of a single line of
code like the above then you've got
problems. Having said that, I suspect that using an index to extract a single
character has to be faster than using a
slice, but I haven
On 13/02/2014 18:37, forman.si...@gmail.com wrote:
I ran across this and I thought there must be a better way of doing it, but
then after further consideration I wasn't so sure.
if key[:1] + key[-1:] == '<>': ...
Some possibilities that occurred to me:
if key.startswith('<') and key.en
On 02/13/2014 10:37 AM, forman.si...@gmail.com wrote:
I ran across this and I thought there must be a better way of doing it, but
then after further consideration I wasn't so sure.
if key[:1] + key[-1:] == '<>': ...
Some possibilities that occurred to me:
if key.startswith('<') and key
In article <4cc09129-43ee-4205-a24c-03f92b594...@googlegroups.com>,
forman.si...@gmail.com wrote:
> I ran across this and I thought there must be a better way of doing it, but
> then after further consideration I wasn't so sure.
>
> if key[:1] + key[-1:] == '<>': ...
>
>
> Some possibilitie
45 matches
Mail list logo