[Tutor] Magic numbers
Phil
phillor9 at gmail.com
Thu Aug 5 02:31:19 EDT 2021
I'm in the process of tidying up a recent project which was littered
with magic numbers. This line of code is called approximately 80 times
per second:
if variable-name < 128:
I'm doing bit shifting calculations and so < 2 ** 7 does make sense or
I could use a pre-calculated global constant. I'm thinking that, for
Python, a global constant might be the better option or doesn't it
matter and only adds an unnecessary complication making the code less
readable.
It's not a matter of life or death, just wondering.
--
Regards,
Phil
More information about the Tutor
mailing list