Skip to content

Commit

Permalink
Merge pull request #273 from moradology/feature/rm-extra-deepcopies
Browse files Browse the repository at this point in the history
Remove unnecessary deepcopies
  • Loading branch information
lossyrob authored Mar 11, 2021
2 parents eebfe89 + 1b0432a commit 4728fab
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Fix handling of optional properties when using apply on view extension ([#259](https://github.com/stac-utils/pystac/pull/259))
- Fixed issue with setting None into projection extension fields that are not required breaking validation ([#269](https://github.com/stac-utils/pystac/pull/269))
- Remove unnecessary `deepcopy` calls in `to_dict` methods to avoid costly overhead ([#273](https://github.com/stac-utils/pystac/pull/273))


### Changed

Expand Down
2 changes: 1 addition & 1 deletion pystac/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def to_dict(self, include_self_link=True):
if self.title is not None:
d['title'] = self.title

return deepcopy(d)
return d

def clone(self):
clone = Catalog(id=self.id,
Expand Down
10 changes: 5 additions & 5 deletions pystac/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def to_dict(self, include_self_link=True):
if self.summaries is not None:
d['summaries'] = self.summaries

return deepcopy(d)
return d

def clone(self):
clone = Collection(id=self.id,
Expand Down Expand Up @@ -213,7 +213,7 @@ def to_dict(self):
"""
d = {'spatial': self.spatial.to_dict(), 'temporal': self.temporal.to_dict()}

return deepcopy(d)
return d

def clone(self):
"""Clones this object.
Expand Down Expand Up @@ -315,7 +315,7 @@ def to_dict(self):
dict: A serializion of the SpatialExtent that can be written out as JSON.
"""
d = {'bbox': self.bboxes}
return deepcopy(d)
return d

def clone(self):
"""Clones this object.
Expand Down Expand Up @@ -418,7 +418,7 @@ def to_dict(self):
encoded_intervals.append([start, end])

d = {'interval': encoded_intervals}
return deepcopy(d)
return d

def clone(self):
"""Clones this object.
Expand Down Expand Up @@ -505,7 +505,7 @@ def to_dict(self):
if self.url is not None:
d['url'] = self.url

return deepcopy(d)
return d

@staticmethod
def from_dict(d):
Expand Down
4 changes: 2 additions & 2 deletions pystac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def to_dict(self, include_self_link=True):
for key in self.extra_fields:
d[key] = self.extra_fields[key]

return deepcopy(d)
return d

def clone(self):
clone = Item(id=self.id,
Expand Down Expand Up @@ -475,7 +475,7 @@ def to_dict(self):
if self.roles is not None:
d['roles'] = self.roles

return deepcopy(d)
return d

def clone(self):
"""Clones this asset.
Expand Down
4 changes: 2 additions & 2 deletions pystac/link.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from copy import (copy, deepcopy)
from copy import copy
from enum import Enum

from pystac import STACError
Expand Down Expand Up @@ -211,7 +211,7 @@ def to_dict(self):
for k, v in self.properties.items():
d[k] = v

return deepcopy(d)
return d

def clone(self):
"""Clones this link.
Expand Down

0 comments on commit 4728fab

Please sign in to comment.