<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, 18 Jul 2017 at 09:07 Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Raymond Hettinger:<br>
-----------------<br>
 > One minor grumble:  I think we need to give careful cost/benefit considerations to<br>
 > optimizations that complicate the implementation.  Over the last several years, the<br>
 > source for Python has grown increasingly complicated.  Fewer people understand it<br>
 > now. It is much harder to newcomers to on-ramp.  The old-timers (myself included)<br>
 > find that their knowledge is out of date.  And complexity leads to bugs (the C<br>
 > optimization of random number seeding caused a major bug in the 3.6.0 release; the<br>
 > C optimization of the lru_cache resulted in multiple releases having a hard to find<br>
 > threading bugs, etc.).  It is becoming increasingly difficult to look at code and<br>
 > tell whether it is correct (I still don't fully understand the implications of the<br>
 > recursive constant folding in the peephole optimizer for example).    In the case<br>
 > of this named tuple proposal, the complexity is manageable, but the overall trend<br>
 > isn't good and I get the feeling the aggressive optimization is causing us to<br>
 > forget key parts of the zen-of-python.<br>
<br>
Nick Coghlan:<br>
-------------<br>
> As another example of this: while trading the global import lock for<br>
> per-module locks eliminated most of the old import deadlocks, it turns<br>
> out that it *also* left us with some fairly messy race conditions and<br>
> more fragile code (I still count that particular case as a win<br>
> overall, but it definitely raises the barrier to entry for maintaining<br>
> that code).<br>
><br>
> Unfortunately, these are frequently cases where the benefits are<br>
> immediately visible (e.g. faster benchmark results, removing<br>
> longstanding limitations on user code), but the downsides can<br>
> literally take years to make themselves felt (e.g. higher defect rates<br>
> in the interpreter, subtle bugs in previously correct user code that<br>
> are eventually traced back to interpreter changes).<br>
<br>
Barry Warsaw:<br>
------------<br>
 > Regardless of whether [namedtuple] optimization is a good idea or not, start up<br>
 > time *is* a serious challenge in many environments for CPython in particular and<br>
 > the perception of Python’s applicability to many problems.  I think we’re better<br>
 > off trying to identify and address such problems than ignoring or minimizing them.<br>
<br>
Ethan Furman:<br>
------------<br>
Speed is not the only factor, and certainly shouldn't be the first concern, but once<br>
we have correct code we need to follow our own advice:  find the bottlenecks and optimize<br>
them.  Optimized code will never be as pretty or maintainable as simple, unoptimized<br>
code but real-world applications often require as much performance as can be obtained.<br></blockquote><div><br></div><div>For me it's a balance based on how critical the code is and how complicated the code will become long-term. I think between Victor and me we maybe have 1 person/week of paid work time on CPython and the rest is volunteer time, so there always has to be some consideration as to whether maintenance will become untenable long-term (this is why complex is better than complicated pretty much no matter what).<br><br></div><div>In namedtuple's case, Raymond designed something that was useful with an elegant solution. Unfortunately namedtuple is a victim of its own success and became a bottleneck when it came to startup time in apps that used it extensively as well as being a sticking point for anyone who wanted to askew exec(). So now we're keeping the usefulness/API design aspect and are being pragmatic about the fact that we want to rework the elegant design to be computationally cheaper so it's no longer an obvious performance penalty at app startup for people who use it a lot. And so now the work is trying to balance the pragmatic performance aspect with the long-term maintenance aspect.<br></div></div></div>