Python dynamic code replacement
Dec 31, 2004 20:34 · 161 words · 1 minute read
It’s interesting the stuff you see when you’re looking at an aggregator. Michael Lucas-Smith of Software WithStyle writes about how updating live server code is so easy in Smalltalk. You replace the code, and all of the instances of those classes immediately get the new behavior.
Not so in Python, laments Chui Tey. He says that Twisted has a metaclass trick to do this and mentions one on ASPN. I’m not sure if this is the one, but the RubyClass hack does look like it’s designed for code replacement.
There was debate following Guido’s discussion of optional static typing in Python about whether adding static typing is a good use of time. While Python’s metaclasses do allow addition of all sorts of interesting behavior, I do think that supporting Smalltalk-like live system updating is a bigger win for Python developers than static typing would be.
Update: I’ve corrected the mention of Michael Lucas-Smith’s employer based on the comment from James Robertson.