
On 3/31/18 5:43 PM, Steven D'Aprano wrote:
But we could avoid that runtime cost if the keyhole optimizer performed the dedent at compile time:
triple-quoted string literal .dedent()
could be optimized at compile-time, like other constant-folding.
There are a lot of expressions of the form constexpr.method(constexpr) that could be safely evaluated at compile time and currently aren't. It also occurred to me that if there were a set.frozen method returning a frozenset, then (with compiler support) you could write frozenset literals without new syntax. And if dict.get and dict.__getitem__ (including the operator syntax for the latter) made compile-time (frozen)dict literals the way "in {...}" already makes frozenset literals, it would give you a functional O(1) switch statement for some simple cases. -- Ben