4 ms·
I don’t understand why this was implemented the way it is (keeping the binary representation using strings with one bit/character). I would think using fracti
by Someone 5y ago
I don’t understand why this was implemented the way it is (keeping the binary representation using strings with one bit/character).
I would think using fractions (https://docs.python.org/3/library/fractions.html https://docs.python.org/3/library/fractions.html) and doing conversion from/to binary on read/write would be faster unless you do very little math and thus spend most of your time reading and writing these numbers.
As a bonus (IMO) those also give you exact representations of ⅓, ⅕, etc, so calculations involving them can have more accurate results by doing the lossy conversion only when printing the binary representation.
What do I overlook?