Steve Holden a écrit :
> Bruno Desthuilliers wrote:
>
>> Steve Holden a écrit :
>
> [...]
>
>>>
>>> Probably not really necessary, though, and they do say that premature
>>> optimization is the root of all evil ...
>>
>>
>> I wouldn't call this one "premature" optimization, since it doesn't
>>
Duncan Booth <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
I went through your example to get timings for my machine, and I
ran into an issue I didn't expect.
My bat file did the following 10 times in a row:
(the command line wraps in this post)
call timeit -s "s='abracadabra1'*1000;t='
Bruno Desthuilliers wrote:
> Steve Holden a écrit :
[...]
>>
>> Probably not really necessary, though, and they do say that premature
>> optimization is the root of all evil ...
>
> I wouldn't call this one "premature" optimization, since it doesn't
> change the algorithm, doesn't introduce (muc
"Tim Williams" <[EMAIL PROTECTED]> wrote:
> Isn't slicing still faster than startswith?As you mention timeit,
> then you should probably add slicing to the pot too :)
>
Possibly, but there are so many other factors that affect the timing
that writing it clearly should be your first choice.
Steve Holden a écrit :
> TheFlyingDutchman wrote:
>>> Else, you could as well write your own testing function:
>>>
>>> def str_starts_with(astring, *prefixes):
>>>startswith = astring.startswith
>>>for prefix in prefixes:
>>> if startswith(prefix):
>>>return true
>>>return
TheFlyingDutchman wrote:
>> Else, you could as well write your own testing function:
>>
>> def str_starts_with(astring, *prefixes):
>>startswith = astring.startswith
>>for prefix in prefixes:
>> if startswith(prefix):
>>return true
>>return false
>>
>
> What is the reason
> Else, you could as well write your own testing function:
>
> def str_starts_with(astring, *prefixes):
>startswith = astring.startswith
>for prefix in prefixes:
> if startswith(prefix):
>return true
>return false
>
What is the reason for
startswith = astring.startswith
On 06/09/07, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
>
> You may want to try with a regexp, but I'm not sure it's worth it (hint:
> the timeit module is great for quick small benchmarks).
>
> Else, you could as well write your own testing function:
>
> def str_starts_with(astring, *prefixes)
[EMAIL PROTECTED] a écrit :
> Hi
>
> startswith( prefix[, start[, end]]) States:
>
> Return True if string starts with the prefix, otherwise return False.
> prefix can also be a tuple of suffixes to look for. However when I try
> and add a tuple of suffixes I get the following error:
>
> Type E
On Sep 6, 7:09 am, [EMAIL PROTECTED] wrote:
> Hi
>
> startswith( prefix[, start[, end]]) States:
>
> Return True if string starts with the prefix, otherwise return False.
> prefix can also be a tuple of suffixes to look for. However when I try
> and add a tuple of suffixes I get the following erro
On Thu, 2007-09-06 at 07:09 -0700, [EMAIL PROTECTED] wrote:
> Hi
>
> startswith( prefix[, start[, end]]) States:
>
> Return True if string starts with the prefix, otherwise return False.
> prefix can also be a tuple of suffixes to look for. However when I try
> and add a tuple of suffixes I get
[EMAIL PROTECTED] wrote:
> Hi
>
> startswith( prefix[, start[, end]]) States:
>
> Return True if string starts with the prefix, otherwise return False.
> prefix can also be a tuple of suffixes to look for.
That particular aspect of the functionality (the multiple
prefixes in a tuple) was only
Hi
startswith( prefix[, start[, end]]) States:
Return True if string starts with the prefix, otherwise return False.
prefix can also be a tuple of suffixes to look for. However when I try
and add a tuple of suffixes I get the following error:
Type Error: expected a character buffer object
For
13 matches
Mail list logo