From: neelk at brick.cswv.com (Neel Krishnaswami)
Date: 26 May 1999 21:47:26 -0500
Subject: Evil hack of the day
References: <7ihvh9$1bm$1@brick.cswv.com> <Pine.LNX.4.10.9905262141420.14143-100000@NEW93126179.columbus.rr.com>
Message-ID: <7iibnu$1ph$1@brick.cswv.com>
X-UID: 1757                                                

In article <Pine.LNX.4.10.9905262141420.14143-100000 at NEW93126179.columbus.rr.com>,
Dan Eble  <eble at ticalc.org> wrote:
>On 26 May, Neel Krishnaswami wrote in comp.lang.python:
>
>NK> This leads to the evil version:
>NK> 
>NK> >>> def evil(n=0):
>NK> ... 	n = n + 1
>NK> ... 	globals()['evil'].func_defaults = (n,)
>NK> ... 	return n
>NK> ...
>
>
>That doesn't work for me.  Observe,
>
>
>Python 1.5.1 [...rest snipped...]
 ^^^^^^^^^^^^

There's the reason right there. Python 1.5.2 shows some rather
noticeable increases in dynamism over the previous version. Another
example: you can reassign the __bases__ attribute of a class in 1.5.2,
and you can't in 1.5.1.

It makes sense, in a perverse sort of way: since Python is already 
too dynamic to optimize efficiently, there's no real cost to going
whole-hog on making the language changeable at run-time.


Neel




