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

Performance: Faster network.copy(), perhaps using copy.deepcopy #785

Open
connortann opened this issue Nov 13, 2023 · 0 comments
Open

Performance: Faster network.copy(), perhaps using copy.deepcopy #785

connortann opened this issue Nov 13, 2023 · 0 comments

Comments

@connortann
Copy link

connortann commented Nov 13, 2023

At present, copying a network with pypsa.Network().copy() takes a surprisingly long time. For some workflows this actually seems to be a performance bottleneck.

I noticed that using the builtin copy.deepcopy seems to do the same job much faster:

import pypsa
import copy

n = pypsa.examples.ac_dc_meshed()
n2 = n.copy()  # takes about 158ms
n3 = copy.deepcopy(n)  # takes about 5 ms

Would this be a suitable alternative implementation? Are there any issues with using copy.deepcopy?

I can look into making a PR if that would be of interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant