graphiti/graphiti_core/utils
codeflash-ai[bot] 2110dbe564
️ Speed up function validate_entity_types by 70%
Here is an optimized version of your program.  
### Major inefficiency  
The code computed `EntityNode.model_fields.keys()` **every call** to the function, but that is invariant and need only be computed once per module. Likewise, it looked up `.keys()` for every entity type model, though these could be checked far more efficiently via set intersection.



### Key performance improvements.
- `EntityNode.model_fields.keys()` evaluated **once**, as a set, and reused.
- Comparison per entity type uses `set` intersection (O(min(N, M))) instead of repeated linear search.  
- Only a single scan over each entity type model's fields, not recomputed unnecessarily.

The function signature and error handling are unchanged, and all preserved comments are respected. This implementation will be significantly faster for many input types.
2025-07-21 00:23:15 +00:00
..
maintenance bulk utils update (#727) 2025-07-15 11:42:08 -04:00
ontology_utils ️ Speed up function validate_entity_types by 70% 2025-07-21 00:23:15 +00:00
__init__.py refactor: use utc_now() for consistent UTC datetime handling (#234) 2024-12-09 10:36:04 -08:00
bulk_utils.py Bulk updates (#732) 2025-07-16 02:26:33 -04:00
datetime_utils.py refactor: use utc_now() for consistent UTC datetime handling (#234) 2024-12-09 10:36:04 -08:00