Re: Faster lower() command
jacques deschĂȘnes wrote:
> Why euphoria interpreter should create 5 or 6 * 1000000 long sequence?
> return o + (o>='A' and o<='Z')*32 -- work as well with atom or sequence
tmp1 = (o>='A') -- a 1000000 sequence of 0 and 1
tmp2 = (o<='Z') -- a 1000000 sequence of 0 and 1
tmp1 = tmp1 and tmp2 -- "" ""
tmp1 *= 32 -- "" of 0 and 32
tmp1 = o+tmp1 -- "" (the result)
return tmp1
I get far more consistent results when called in a for loop, and I have noticed
tests like this tend to stongly favour whatever comes second, best to run them in
separate programs in the name of equality.
There might be a margin of say 5% for the 1-liner, but it is nothing like 4 or 5
times faster as you might at first expect. The more you play with the above two
code snippets, the more you realise they are essentially the same.
> I don't know how the loop is implemented inside euuphoria interpreter but
> there is place for optimization!
I could enter a long rant about why sequence ops are such a bad idea, but I
think I'll spare you today.
Chris Bensler wrote:
>Pete: peek() will accept peek({lp,0}) which will result in a null string
Thanks, I'll edit my copy of that routine.
Regards,
Pete
|
Not Categorized, Please Help
|
|