[Python-Dev] The decorator module
Raymond Hettinger
python at rcn.com
Mon May 9 08:34:38 CEST 2005
[Michele Simionato]
> Is there in the plans any facility to copy functions? Currently I am
doing
>
> def copyfunc(func):
> "Creates an independent copy of a function."
> c = func.func_code
> nc = new.code(c.co_argcount, c.co_nlocals, c.co_stacksize,
c.co_flags,
> c.co_code, c.co_consts, c.co_names, c.co_varnames,
> c.co_filename, c.co_name, c.co_firstlineno,
> c.co_lnotab, c.co_freevars, c.co_cellvars)
> return new.function(nc, func.func_globals, func.func_name,
> func.func_defaults, func.func_closure)
>
> and I *hate* it!
Sounds reasonable.
Choices:
- submit a patch adding a __copy__ method to functions,
- submit a patch for the copy module, or
- submit a feature request, assign to me, and wait.
Raymond Hettinger
More information about the Python-Dev
mailing list