[Python-3000] Iterators for dict keys, values, and items == annoying :)

Ian Bicking ianb at colorstudy.com
Fri Mar 31 08:41:49 CEST 2006


Alex Martelli wrote:
> On Mar 30, 2006, at 5:53 PM, Greg Ewing wrote:
>     ...
>>> Generally speaking I've remained suspicious of adaptation.
>> I think to most people it seems like a solution
>> looking for a problem. In all the code I've ever
>> written, plain duck typing has been perfectly
>> adequate. I'm willing to concede that it might
>> have use in some specialised areas such as Zope,
>> but there doesn't seem to be any general demand
>> for it.
> 
> I concede that the peasants haven't (yet!-) stormed Guido's castle  
> with pitchforks and torches to get him to approve PEP 246, but I view  
> that as me not having done a good job of communication.  Each and  
> every time a new ad-hoc-adaptation gets into the language (e.g., most  
> recently the __index__ one), I'm tempted to point out how much better  
> life would be with adaptation... but these days I mostly shrug and  
> get on with my life instead.

There's nothing stopping people from using adaptation right now.  And 
yet it only has happened in a few very specific communities -- Twisted 
and Zope 3.  And probably several small projects and whatnot, but mass 
adoption has really stayed inside those communities.  There's no doubt 
lots of interesting interpretations one could make about this, about 
social dynamics and goals and problem areas and whatnot, but whatever it 
is, people are not scrambling to get their hands on adaptation.

Which is not to say that there is no use to adaptation, just that as 
currently formulated it's a difficult sell.  I think the ambition of the 
current implementations and usage might be part of this.  Or maybe the 
way it changes the system, and demands a great deal from the system.  It 
only really starts getting interesting when everyone starts to use 
interfaces and adaptation, and that requires more buy-in than most 
people are willing to give.

> And that's just for somebody using one humble library -- adaptation  
> really shines when you're using independently developed frameworks.   
> If the framework consuming X requested adaptation-to-X on all objects  
> it's passed, rather than checking them for this or that ad-hoc  
> protocol, as longs as a suitable adapter is registered the framework  
> producing Y's and the one consuming X's would just fit with each  
> other with no effort required on the part of the longsuffering  
> application developer.

Does it really shine?  I don't know.  I think the geometrically 
increasing returns from more use of adaptation and interfaces also works 
against it -- because the returns get geometrically smaller as you 
consider the incremental value of introducing adaptation into a system. 
  I don't see multiframework integration using adaptation.  I see 
frameworks that are loosely coupled but otherwise insular -- Twisted and 
Zope 3 -- using adaptation.  I don't even get the impression they use 
each other's code that much, even though they use the same adaptation 
system.

Explicit, stupid, obvious code is how integration works.  Adaptation is 
too clever, and cleverness kills integration IMHO.

-- 
Ian Bicking  |  ianb at colorstudy.com  |  http://blog.ianbicking.org


More information about the Python-3000 mailing list