Encapsulation in Python

Chris Angelico rosuav at gmail.com
Mon Mar 14 20:58:40 EDT 2016


On Tue, Mar 15, 2016 at 11:54 AM, BartC <bc at freeuk.com> wrote:
>> In Python, there's no reason to restrict 'switch'
>> to integers, so I would expect its semantics to be based on either
>> equality comparisons or inequality comparisons
>
>
> I use two forms of switch: one for integers only (very fast), and the other
> for any other values, which does tests in sequence.

I'm not sure what you gain by restricting to integers that you
couldn't also gain with other hashable types. Can you elaborate on
these optimizations?

ChrisA



More information about the Python-list mailing list