Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ Speed up method `AstraDBVectorStoreComponent.reset_collection_list…
…` by 12% in PR #6048 (`bugfix-dev-astradb`) To optimize the given Python program for better runtime performance, we can reduce the number of times certain functions are called and avoid redundant computations. We'll make changes to avoid multiple calls to retrieve the collection data and reuse already created objects where possible. ### Changes Made. 1. **Caching Keyspace**: By caching the keyspace value in a variable (`keyspace`), we avoid multiple calls to the `get_keyspace()` method. 2. **Inlined Metadata Extraction**: Instead of extracting metadata in the list comprehension directly, we define a helper function `get_collection_metadata` to avoid re-fetching data. 3. **Single Pass for Options and Metadata**: Combined options and metadata generation into a single pass loop to avoid repeated dictionary comprehension. These changes reduce function calls, loop iterations, and improve the readability and maintainability of the code.
- Loading branch information