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

Remove unnecessary deepcopies #273

Merged
merged 2 commits into from
Mar 11, 2021

Conversation

moradology
Copy link
Contributor

Calls to deepcopy are fairly expensive when working with large number of STACs. In to_dict methods, a dictionary d is instantiated only to have deepcopy applied to it for the return value. This seems to be unnecessary.

Here's snakeviz output of some cProfile timings.
Before:
image

After:
image

It should be noted that the after includes also the use of orjson to optimize ser/de operations. This optimization can be left out of pystac because it requires an external dependency and because it can easily be plugged in through a STAC_IO subclass

@matthewhanson
Copy link
Member

matthewhanson commented Mar 10, 2021

nice catch @moradology , this looks good to me, there doesn't seem to be any reason to do a deepcopy of a locally defined variable before returning,
I'm also interested in improving the performance of PySTAC with large catalogs and interested in any optimizations you've tried.

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

Successfully merging this pull request may close these issues.

3 participants