The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

BartC bc at freeuk.com
Mon Mar 21 21:00:20 EDT 2016


On 22/03/2016 00:42, Mark Lawrence wrote:
> On 22/03/2016 00:18, BartC wrote:
>> On 21/03/2016 23:50, Terry Reedy wrote:
>>> On 3/21/2016 8:43 AM, BartC wrote:
>>>
>>>> This tests highlights the benefits of an O(1) switch statement.
>>>
>>> So why are you not taking advantage of Python's O(1) dict lookup?
>>>
>> I've already reported using a list lookup which is also O(1), and it
>> didn't really help. I doubt a dict lookup is going to be faster (but
>> Python has surprised me before).
>
> Please explain how you managed to make the list lookup O(1).

It's not a 'lookup' in the sense of searching. It's just normal 
indexing. The 'key' will be an ASCII code 0 to 127.

-- 
Bartv




More information about the Python-list mailing list