mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-13 16:28:38 +00:00
Base.to_dict() and __repr__() ran sqlalchemy.inspect(type(self)).mapper reflection on every call, but to_dict() is invoked once per row when serializing ORM results (e.g. every event in a messages/events page). The mapped columns are fixed at class-definition time, so cache the column keys per class with functools.cache and iterate the cached tuple. Behavior is unchanged. Fixes #3653.