Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support __copy__ and __deepcopy__? #35

Open
cjdoris opened this issue Aug 23, 2021 · 3 comments
Open

Support __copy__ and __deepcopy__? #35

cjdoris opened this issue Aug 23, 2021 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@cjdoris
Copy link
Collaborator

cjdoris commented Aug 23, 2021

juliacall.AnyValue.__copy__ and __deepcopy__ could call Julia's copy and deepcopy.

Conversely, copy(::Py) and deepcopy_internal(::Py, ::IdDict) could call Python's copy.copy and copy.deepcopy.

https://docs.python.org/3/library/copy.html

@cjdoris
Copy link
Collaborator Author

cjdoris commented Aug 23, 2021

We can support memos by including the Julia memo dict at a special key in the Python memo dict, and vice versa.

@cjdoris cjdoris added the enhancement New feature or request label Oct 2, 2021
@stevengj
Copy link
Member

stevengj commented May 2, 2022

Note that you'll probably want to define Base.deepcopy_internal to at minimum increment the reference count, since otherwise calling deepcopy(::Py) in Julia will use the default implementation (that will just copy the pointer, which might lead to crashes since then the refcount will be wrong).

@github-actions github-actions bot added the stale Issues about to be auto-closed label Sep 22, 2023
@JuliaPy JuliaPy deleted a comment from github-actions bot Sep 22, 2023
@cjdoris cjdoris added help wanted Extra attention is needed and removed stale Issues about to be auto-closed labels Sep 22, 2023
@stevengj
Copy link
Member

See JuliaPy/PyCall.jl#1039 for how PyCall.jl does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants