>
> That would work, but would be slower for the reference implementation
> due to the repeated `isinstance(value, int)` checks.
>
If you wanted to avoid that you could use match/case inside the "case
int()" instead, i.e.:
case int():
match value:
case _ if value < 8:
// do things
case _ if value < 1 << 8:
// do things
...
case _:
// raise some kind of error
but that might be madness.
> I think the repeated `int()` cases do not help readability.
> Which form do you think is more readable?
>
I think the form I suggested is more readable and also I think it is more
PEP622-like and that it is easier to reason about/test/debug/maintain, but
that's just my opinion! Not sure how important the speed difference is to
this example.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/VAKQAJ2BTATMXG2JUKKEO4BTMJDUWGQS/
Code of Conduct: http://python.org/psf/codeofconduct/