Asked and answered! > * There are an unlimited number of derived (non-SI) and compound units > that people will want to use.
Unlimited? You sure that problem can't be bounded? There are few things I can think of that could bound this problem in a performance-friendly manner. In terms of the internal representation of units, the representation that is use for machine calculations, there are only 7 units that need to be supported. Everything else is a product of powers of these 7 units. So you can represent every combination with 7 counters. And those counters do not need to have lots of bits. If you're using units in a way that leads to meters**255, then you might have a bug in your code, or you might be doing something that doesn't really need units. 4-8 bits are enough to store the powers of the 7 SI quantities (4-8 bytes). Translating those 7 quantities to the few hundred standard derived units can be handled by higher level libraries, which may still require counters of multiple types of units depending on the level and breadth of support being maintained. > * To say nothing of having to deal with adjustments to the definitions, > e.g. a kilometre in 1920 is not the same as a kilometre in 2020, and > applications that care about high precision may care about the > difference. True. It's a problem. Might require additional unit sets and/or namespaces. But in 3020, will we still be using Python? > Having a single interpreter-wide namespace for units will cause many > name collisions. I expect that units should be scoped like variables > are, with some variant of the LEGB (Local, Enclosing, Global, Builtin) > scoping rules in place. Yes, yes, yes! _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/IJXF4E6LUOV2VH5BR2DSHQJZCXGPEXM4/ Code of Conduct: http://python.org/psf/codeofconduct/