Commit 12defc1
committed
(improvement) metadata: single-pass column classification in _build_table_columns
Rewrite _build_table_columns to classify columns by kind in a single
pass instead of iterating col_rows three times with list comprehensions.
This also fixes a bug where the third pass filtered on 'clustering_key'
instead of 'clustering', causing clustering columns to leak through and
get re-processed as regular columns.
Additionally, use in-place sort() instead of sorted() to avoid creating
intermediate list copies, and append the already-built column_meta
object to partition_key/clustering_key instead of re-looking it up
from meta.columns by name.
Combined benchmark results for the full optimization series (A-F):
Row creation + access: 323 ns/row vs 485 ns/row (1.50x faster)
_build_table_columns: 9.0 us/table vs 9.9 us/table (1.10x faster)
Full pipeline (100 tables x 20 cols): 0.79 ms vs 1.57 ms (1.98x faster)
Memory per row: 48 bytes vs 272 bytes (5.7x reduction)
__slots__ per instance: 80 bytes (saves ~104 bytes __dict__ overhead)1 parent 8ed0269 commit 12defc1
1 file changed
Lines changed: 1746 additions & 624 deletions
0 commit comments