On 2017-09-12, Victor Stinner wrote:
> Instead of modifying the Python grammar, the alternative is to enhance
> float(str) to support it:
> 
> k = float("0x1.2492492492492p-3") # 1/7

Making it a different function from float() would avoid backwards
compatibility issues. I.e. float() no longer returns errors on some
inputs.

E.g.

    from math import hexfloat
    k = hexfloat("0x1.2492492492492p-3")

I still think a literal syntax has merits.  The above cannot be
optimized by the compiler as it doesn't know what hexfloat() refers
to.  That in turn destroys constant folding peephole stuff that uses
the literal.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to