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).

One problem is how to attach the handling code to the entry in the list or as the value in the dict. With the list, I stored a function reference.

I suspect that a switch implemented Python-style wouldn't be dramatically faster either. But the handling code can be expressed in-line.

--
bartc


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to