Skip to content

Perf: Define __slots__ in element classes to reduce memory usage of elements#555

Merged
adrien-berchet merged 4 commits intogeoalchemy:masterfrom
adrien-berchet:slots
May 16, 2025
Merged

Perf: Define __slots__ in element classes to reduce memory usage of elements#555
adrien-berchet merged 4 commits intogeoalchemy:masterfrom
adrien-berchet:slots

Conversation

@adrien-berchet
Copy link
Copy Markdown
Member

No description provided.

@adrien-berchet adrien-berchet requested a review from Copilot May 12, 2025 22:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aims to reduce memory usage for spatial element classes by defining slots to prevent dynamic attribute creation, while also updating benchmark parameters in tests for performance measurement.

  • Updated benchmark parameter value from 350 to 100 in two test cases.
  • Added slots declarations in element classes to optimize memory usage.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/benchmarks/test_insert_select.py Updated benchmark parameters to adjust test load conditions.
geoalchemy2/elements.py Introduced slots for the base _SpatialElement and its subclasses to reduce memory usage.
Comments suppressed due to low confidence (1)

tests/benchmarks/test_insert_select.py:294

  • [nitpick] The benchmark parameter value has been reduced from 350 to 100; please verify that this change still adequately tests higher-load scenarios for performance.
pytest.param(100, marks=pytest.mark.long_benchmark),

@adrien-berchet adrien-berchet merged commit c139cdb into geoalchemy:master May 16, 2025
8 checks passed
@adrien-berchet adrien-berchet deleted the slots branch May 16, 2025 17:33
@adrien-berchet adrien-berchet linked an issue May 16, 2025 that may be closed by this pull request
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.

Use __slots__ in elements

2 participants