[Python-ideas] Hexadecimal floating literals

Serhiy Storchaka storchaka at gmail.com
Fri Sep 22 06:56:21 EDT 2017


21.09.17 18:23, Victor Stinner пише:
> My vote is now -1 on extending the Python syntax to add hexadecimal
> floating literals.
> 
> While I was first in favor of extending the Python syntax, I changed
> my mind. Float constants written in hexadecimal is a (very?) rare use
> case, and there is already float.fromhex() available.
> 
> A new syntax is something more to learn when you learn Python. Is it
> worth it? I don't think so. Very few people need to write hexadecimal
> constants in their code.

Initially I was between -0 and +0. The cost of implementing this feature 
is not zero, but it looked harmless (while almost useless). But after 
reading the discussion (in particular the comments of proponents) I'm 
closer to -1.

This feature can be useful for very few people. And they already have 
float.fromhex(). Taking to account the nature of Python the arguments 
for literals are weaker than in case of statically compiled languages. 
For the rest of users it rather adds confusion and misunderstanding. And 
don't forgot about non-zero cost. You will be impressed by the number of 
places just in the CPython core and stdlib that should be updated for 
supporting a new type of literals.



More information about the Python-ideas mailing list