[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    Re: [Python-ideas] Multi-line string indentation
From:       Ben Rudiak-Gould <benrudiak () gmail ! com>
Date:       2019-02-08 21:30:58
Message-ID: CAANSMWqmPNYOkmJigZpxKUUhOMNEvjFrx5iL1NdfNbN4tbTGpQ () mail ! gmail ! com
[Download RAW message or body]

> 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
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic