python-makefun icon indicating copy to clipboard operation
python-makefun copied to clipboard

Should we add an explicit `funcopy` function ?

Open smarie opened this issue 3 years ago • 2 comments

def funcopy(f):
    """Creates an actual copy of a function, since python copy() does not"""
    return partial(f)

smarie avatar Sep 07 '22 19:09 smarie

Just curious: what does copy.deepcopy do that I'm missing that precludes it from being a "true" copy?

makslevental avatar Apr 17 '24 18:04 makslevental

Thanks @makslevental !

See discussions here :

  • https://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python
  • https://stackoverflow.com/questions/13503079/how-to-create-a-copy-of-a-python-function

I did not follow all of this so not sure this is still needed / relevant. This original issue was a way for me to remember the (odd but existing) practice of copying a function using partial, and remembering that maybe there was an actual need.

Would need some digging to confirm.

smarie avatar Jul 12 '24 11:07 smarie