Skip to content

Commit 4728fab

Browse files
authored
Merge pull request #273 from moradology/feature/rm-extra-deepcopies
Remove unnecessary deepcopies
2 parents eebfe89 + 1b0432a commit 4728fab

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

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

1012
### Changed
1113

pystac/catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def to_dict(self, include_self_link=True):
381381
if self.title is not None:
382382
d['title'] = self.title
383383

384-
return deepcopy(d)
384+
return d
385385

386386
def clone(self):
387387
clone = Catalog(id=self.id,

pystac/collection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def to_dict(self, include_self_link=True):
107107
if self.summaries is not None:
108108
d['summaries'] = self.summaries
109109

110-
return deepcopy(d)
110+
return d
111111

112112
def clone(self):
113113
clone = Collection(id=self.id,
@@ -213,7 +213,7 @@ def to_dict(self):
213213
"""
214214
d = {'spatial': self.spatial.to_dict(), 'temporal': self.temporal.to_dict()}
215215

216-
return deepcopy(d)
216+
return d
217217

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

320320
def clone(self):
321321
"""Clones this object.
@@ -418,7 +418,7 @@ def to_dict(self):
418418
encoded_intervals.append([start, end])
419419

420420
d = {'interval': encoded_intervals}
421-
return deepcopy(d)
421+
return d
422422

423423
def clone(self):
424424
"""Clones this object.
@@ -505,7 +505,7 @@ def to_dict(self):
505505
if self.url is not None:
506506
d['url'] = self.url
507507

508-
return deepcopy(d)
508+
return d
509509

510510
@staticmethod
511511
def from_dict(d):

pystac/item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def to_dict(self, include_self_link=True):
297297
for key in self.extra_fields:
298298
d[key] = self.extra_fields[key]
299299

300-
return deepcopy(d)
300+
return d
301301

302302
def clone(self):
303303
clone = Item(id=self.id,
@@ -475,7 +475,7 @@ def to_dict(self):
475475
if self.roles is not None:
476476
d['roles'] = self.roles
477477

478-
return deepcopy(d)
478+
return d
479479

480480
def clone(self):
481481
"""Clones this asset.

pystac/link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from copy import (copy, deepcopy)
1+
from copy import copy
22
from enum import Enum
33

44
from pystac import STACError
@@ -211,7 +211,7 @@ def to_dict(self):
211211
for k, v in self.properties.items():
212212
d[k] = v
213213

214-
return deepcopy(d)
214+
return d
215215

216216
def clone(self):
217217
"""Clones this link.

0 commit comments

Comments
 (0)