diff --git a/CHANGES.txt b/CHANGES.txt index 21791e90..c75b1c93 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,11 @@ Bug fixes: - A more information exception is now raised by JSONField.get() when the value cannot be decoded (#1463). +Changes: + +- Python coordinate sequence construction has been improved, translating to + better performance in reading Fiona Features from datasets (#1462). + 1.10.1 (2024-09-16) ------------------- diff --git a/fiona/_transform.pyx b/fiona/_transform.pyx index f159fd5f..8dd06ba8 100644 --- a/fiona/_transform.pyx +++ b/fiona/_transform.pyx @@ -160,25 +160,26 @@ def _transform_geom(src_crs, dst_crs, geom, antimeridian_cutting, antimeridian_o factory = new OGRGeometryFactory() - if isinstance(geom, Geometry): - out_geom = recursive_round( - _transform_single_geom(geom, factory, transform, options), precision) - else: - out_geom = [ - recursive_round( - _transform_single_geom(single_geom, factory, transform, options), - precision, - ) - for single_geom in geom - ] - - OCTDestroyCoordinateTransformation(transform) - - if options != NULL: - _csl.CSLDestroy(options) - - OSRRelease(src) - OSRRelease(dst) + try: + if isinstance(geom, Geometry): + out_geom = recursive_round( + _transform_single_geom(geom, factory, transform, options), precision) + else: + out_geom = [ + recursive_round( + _transform_single_geom(single_geom, factory, transform, options), + precision, + ) + for single_geom in geom + ] + + finally: + del factory + OCTDestroyCoordinateTransformation(transform) + if options != NULL: + _csl.CSLDestroy(options) + OSRRelease(src) + OSRRelease(dst) return out_geom