3 ms·
CPython can't do this because it's a change in semantics. You need explicit opt-in from the programmer. Anyway adding this optimisation to CPython would be lik
by IshKebab 2mo ago
CPython can't do this because it's a change in semantics. You need explicit opt-in from the programmer.
Anyway adding this optimisation to CPython would be like putting active aero on a dandy horse.
- pjmlp 2mo agoSome of us would like to have Python finally catch up to Lisp in compiler tooling, but alas. As for change in semantics, apparently that isn't an issue on JS, Java and .NET JITs in adopting more modern architectures.
- aw1621107 2mo ago> apparently that isn't an issue on JS, Java and .NET JITs in adopting more modern architectures. I think it'd be an issue irrespective of the architecture? Optimizations are generally expected to preserve semantics and those languages all specify IEEE 754 semantics which aren't necessarily associative. For instance, from the Java language spec [0]: > Floating-point arithmetic is carried out in accordance with the rules of the IEEE 754 Standard, including for overflow and underflow (§15.4), with the exception of the remainder operator % (§15.17.3). Or the .NET reference [1]: > The Double type complies with the IEC 60559:1989 (IEEE 754) standard for binary floating-point arithmetic. Or the ECMAScript 2027 spec [2]: > Numeric operators such as +, ×, =, and ≥ refer to those operations as determined by the type of the operands. [] When applied to Numbers, the operators refer to the relevant operations within IEEE 754-2019. [0]: https://docs.oracle.com/javase/specs/jls/se26/jls26.pdf https://docs.oracle.com/javase/specs/jls/se26/jls26.pdf [1]: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/types https://learn.microsoft.com/en-us/dotnet/csharp/language-ref... [2]: https://tc39.es/ecma262/#sec-mathematical-operations https://tc39.es/ecma262/#sec-mathematical-operations
- pjmlp 2mo agoRegardless, those optimisations are available on the respective JITs. RyuJIT target CPU modes, breaking change due to dropping support for older hardware, https://github.com/dotnet/docs/issues/48045 https://github.com/dotnet/docs/issues/48045 > Native Image now targets x86-64-v3 architecture by default on AMD64 and provides a new -march option to specify target compatibility. Use -march=compatibility for best compatibility or -march=native for best performance if a native executable is deployed on the same machine or on a machine with the same CPU features. To list all available machine types, use -march=list. https://www.graalvm.org/release-notes/JDK_20 https://www.graalvm.org/release-notes/JDK_20
- aw1621107 2mo ago> those optimisations are available on the respective JITs. I'd assume they aren't applied by default and/or without the programmer explicitly opting in to those altered semantics, though. Would you be able to show otherwise? I don't see how changing targeted instruction sets is relevant here as the instructions you use is orthogonal to whether you assume floating point operations are associative.
- afdbcreid 2mo ago> Regardless, those optimisations are available on the respective JITs. I'm pretty sure this is wrong. No JS engine, RyuJIT or or HotSpot break IEE-754. Java does have intrinsics for algebraic floating point operations (but does not apply them by default and I don't think they're exposed), the other I don't think.