Alan Franzoni a écrit : > Il 23 May 2007 04:53:55 -0700, Siah ha scritto: > > [cut] > > No. > > It's because the *body* of the function gets evaluated every time the > function is called, while the *definition* of the function gets evaluated > just once, when the function is 'declared'. > > Your issue arises when the default value of the function (which is part of > the definition, not of the body) is a mutable object, because it's the very > same default value that gets modified at each time. > > That is. Jython doesn't have the same rules about optimisation of common literals :
[EMAIL PROTECTED]:~$ jython Jython 2.1 on java1.4.2-03 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> () is () 0 >>> 1 is 1 1 >>> def f(d=()) : return d ... >>> f() is f() 1 -- http://mail.python.org/mailman/listinfo/python-list