Performance of list comprehensions vs. map

Tim Peters tim.one at home.com
Fri Sep 7 17:08:19 EDT 2001


[Chris Barker]
> One more question: is it possible for a function to be 
> mutable??

[Skip Montanaro]
> Yes, in theory, from C code.  You could create a new code object 
> and change the function's func_code attribute.  I don't think you
> can do that from Python code, even using the new module.

func_code has been writable for some time.  Here under 2.2a3:

>>> def f():
...     pass
...
>>> def g():
...     return 666
...
>>> f.func_code = g.func_code
>>> f()
666
>>>

> ...
> but-then-just-about-anything's-possible-in-C-ly y'rs,

ya-but-it's-easier-in-python<wink>-ly y'rs  - tim





More information about the Python-list mailing list