Skip to content

Removes sqlalchemy_utils dependency - #356

Closed
mfulgo wants to merge 7 commits into
sqlalchemy-continuum:masterfrom
mfulgo:issue-745
Closed

mfulgo wants to merge 7 commits into
sqlalchemy-continuum:masterfrom
mfulgo:issue-745

Conversation

@mfulgo

@mfulgo mfulgo commented Jul 30, 2024 •

Copy link
Copy Markdown
Contributor

Importing functions from slqalchemy_utils directly causes the entire library to get imported, even though many of the library's modules go unused. Porting only the necessary functions from that library into Continuum should provide improved initialization times.

Closes #357

mfulgo added 6 commits August 8, 2024 12:57
Updates sqlalchemy_utils imports to point at specific packages and
removes a few unused imports.

This was done in hope of not initializing the whole of SA-Utils, but
that requires a different approach.
This is a breaking change because classes copied from SQLAlchemy-Utils
but exposed through this library will have a new parent module.

Utility classes and methods from SQLAlchemy-Utils are all copied into
`sa_utils.py` with no functional changes. Only code required by
Continuum was ported.

Subsequent commits will implement cleanup and other changes discussed in
Updates the `get_primary_keys` method to only return the primary key
columns (without their values) in a list, since the values went unused.
The method is thus renamed to `get_primary_key_columns`.
Quite a bit of the code migrated in from SQLAlchemy-Utils only gets used
within the plugins module. There's no need for us to incur the
initialization expense if those classes and methods aren't needed or
used.

This will only actually have an initialization benefit if the plugins
module does not load every plugin upon import. However, having the code
co-located anyway makes sense.
The function only gets used in one place, so we can move it there and
mark it private.
The function only gets used in one place, so we can move it there and
mark it private.
@mfulgo mfulgo changed the title Optimizes sqlalchemy_utils imports Removes sqlalchemy_utils dependency Aug 8, 2024
Using a relative import allows the library to be more-easily vendored
without having to tweak the import line.
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.

Performance optimizations for imports of sqlalchemy_utils

2 participants