[Python-ideas] In fact, I'm a bit worry about this literal p""

Steven D'Aprano steve at pearwood.info
Mon Dec 31 05:54:37 EST 2018


On Mon, Dec 31, 2018 at 12:48:56AM -0800, Yuval Greenfield wrote:

> In my opinion, only if this change would make 50% of programs run 50%
> faster then it might be worth discussing.

What if it were 100% of programs 25% faster? *wink*

Generally speaking, we don't introduce new syntax as a speed 
optimization. The main reasons to introduce syntax is for convenience 
and to improve the expressiveness of code.

That's why we usually prefer to use operators like + and == instead of 
functions add() and equal(). There's nothing a list comprehension can do 
that a for-loop can't, but list comps are often more expressive. And the 
class statement is just syntactic sugar for type(name, bases, dict), but 
much more convenient.

In this specific case, I don't think that regex literals will add much 
expressiveness:

    regex = re.compile(r"...")
    regex = p("...")

is not that much different.



-- 
Steve


More information about the Python-ideas mailing list