[Python-ideas] Adding "+" and "+=" operators to dict

Chris Barker chris.barker at noaa.gov
Sat Feb 14 00:12:29 CET 2015


On Fri, Feb 13, 2015 at 10:18 AM, Eric Snow <ericsnowcurrently at gmail.com>
wrote:

> > But maybe cPython itself could do an optimization step like that --
> examine
> > an entire expression for types, and if they all support the right
> > operations, re-structure it in a more optimized way.
>
> It's tricky in a dynamic language like Python to do a lot of
> optimization at compile time, particularly in the case in the face of
> operator overloading.


Exactly -- I was thinking this would be a run-time thing. Which  might make
for a major change, as I expect the compiler compiles expressions ahead of
time.

To some extent PyPy is state-of-the-art when in comes to
> optimizations, so it may be worth taking a look if the problem is
> tractable for Python in general.


That might be a way to go -- but it wold probably mean essentially
reimplementing numpy in PyPy -- which PyPy may, in fact already be doing!


> PEP 484 ("Type Hints") may help in a
> number of ways too.


yes, though at least for now -- it seem very focused on the use-case of
pre-run-time type checking (pr compile time, too), so it'll be a while...


>   I suppose there
> are a number of possibilities along that line, but I'm not an expert
> on the compiler and interpreter.


way out of my depth here, too.

Anyway, way OT for this thread -- _maybe_ I'll be able to compress these
thoughts down to start a conversion her about it some day...

-Chris




-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150213/53206bd1/attachment.html>


More information about the Python-ideas mailing list