optimizations to improve performance, add ormar-utils by collerek · Pull Request #1571 · ormar-orm/ormar
Profile-driven optimizations targeting the most expensive ormar functions. Key changes: - Cache alias<->field_name mappings per model class, using Rust build_reverse_alias_map for O(1) lookups (was O(n) linear scan, called 406K times in profiling) - Cache (col_name, field_name) pairs to avoid repeated SA column iteration in own_table_columns and extract_prefixed_table_columns - Use set instead of list for selected_columns membership checks - Cache get_name(lower=True), extract_db_own_fields, ormar_fields_set, and ForeignKey constructors dict - Use frozenset for RelationProxy method check End-to-end benchmark improvements: - iterate: 24-30% faster - first: 26-36% faster - get_all: 18-19% faster - saving: 17-25% faster - select_related: 12-17% faster Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>