Status of optional static typing in Python?

Christian Convey conveycj at npt.nuwc.navy.mil
Thu Jun 22 16:24:32 EDT 2006


Perhaps I'm deluded but I don't think so.  I'll tell you my situation 
and I'd appreciate your take on it...

I'm looking into the design a network simulator.  The simulator has a 
few requirements:

(1) I need to be able to swap in a variety of replacement components 
during different simulations.  I.e., RadioFrequencyChannelModel, 
WiredNetworkChannelModel, etc.  This drives me to want the notion of 
inherited interfaces, partly as a form of documentation.

(2) I want a form of encapsulation (which I realize isn't necessarily 
guaranteed in all possible static typing implementations).  I.e., I want 
to ensure that any code which accesses a ChannelModel only calls those 
methods that are part of the ChannelModel interface.  If there's a 
method RadioFrequencyChannelModel.setBroadcastDistance(...), which isn't 
part of the generic ChannelModel interface, I don't want most of my code 
to be able to start using that particular method, if the code need to be 
able to work with all possible ChannelModel implementations.

(3) I like Interfaces as a matter of documentation.  It helps me to 
thing things through.  I've got a lot of components that must support 
interchangeable implementations: channels, modems, MAC layers, link 
layers, etc.  If I have an abstract MAC_layer interface, it helps me 
think carefully about what every MAC layer ought to provide, and it also 
helps me explain to other people what a MAC layer in my simulator must 
provide.  That is, it helps me better explain to other people how the 
system's major components relate to each other.


Now, I could use Java or C# to get functionality such as interfaces, but 
I loath giving up the general productive goodness of Python.  That's why 
I'm looking for something like interfaces.

But even if we disagree about the wisdom of my intentions, do you know 
if/when Guido's planning to work that stuff into Python?  The last post 
I noticed from him on the topic was from 2005.  At least back then he 
sounded pretty into it.

Thanks,
Christian

Bruno Desthuilliers wrote:
> Christian Convey a écrit :
>> Hi guys,
>>
>> I'm looking at developing a somewhat complex system, and I think some 
>> static typing will help me keep limit my confusion.  
> 
> Then I think you're suffering from an alas too common delusion. Static 
> typing (at least declarative static typing) will only makes your system 
> more complex. But if you want some help in managing complexity, you may 
> want to look at interfaces systems (Zope3 interfaces or Peak's Protocol) 
> and multidispatch (Peak's Protocol dispatch package).
> 

-- 
Christian Convey
Computer Scientist,
Naval Undersea Warfare Centers
Newport, RI
(401) 832-6824
conveycj at npt.nuwc.navy.mil



More information about the Python-list mailing list