[Tutor] Problem with if statements and else statements
Cameron Simpson
cs at zip.com.au
Tue May 30 08:49:16 EDT 2017
On 30May2017 12:06, Peter Otten <__peter__ at web.de> wrote:
>Cameron Simpson wrote:
>> As written it should be a bit slower: to construct a set each member get
>> tested for presence. The cost is in making the set, not in searching it.
>
>No, CPython is a bit smarter than that:
>
>>>> dis.dis('if m in {"1", "January"}: pass')
> 1 0 LOAD_NAME 0 (m)
> 2 LOAD_CONST 3 (frozenset({'1', 'January'}))
Ah, I was wonderig about things like that during today...
[ More cool info snipped... ]
Thanks,
Cameron Simpson <cs at zip.com.au>
More information about the Tutor
mailing list