Skip to content

Commit

Permalink
perf(python): optimize _unpack_schema() (pola-rs#10960)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-keller authored Sep 7, 2023
1 parent bf54d5e commit faa71c5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions py-polars/polars/utils/_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,17 @@ def _unpack_schema(
]
if not column_names and n_expected:
column_names = [f"column_{i}" for i in range(n_expected)]
lookup = {
col: name for col, name in zip_longest(column_names, lookup_names or []) if name
}
lookup = (
{
col: name
for col, name in zip_longest(column_names, lookup_names or [])
if name
}
if lookup_names
else None
)
column_dtypes = {
lookup.get(col[0], col[0]): col[1]
lookup.get(col[0], col[0]) if lookup else col[0]: col[1]
for col in (schema or [])
if not isinstance(col, str) and col[1] is not None
}
Expand Down

0 comments on commit faa71c5

Please sign in to comment.