list() is Python’s built-in list constructor — it creates a new list from any iterable (string ? characters, tuple/range ? elements, set/dict ? keys, etc.), or an empty list when called with no arguments. In 2026, list() remains a fundamental tool in data science (converting iterators, Dask/Polars results, NumPy arrays), software engineering (data normalization, slicing, copying), and functional programming — offering fast, readable, and memory-efficient list creation with full support for comprehensions, unpacking, and chaining in modern pipelines.
Here’s a complete, practical guide to using list() in Python: creation patterns, common conversions, real-world patterns (earthquake data flattening, chunk results, iterable exhaustion), and modern best practices with type hints, performance, mutability, and integration with Dask/Polars/pandas/NumPy/xarray.
Basic list() usage — from iterables or empty.
# Empty list
empty = list()
print(empty) # []
# From string ? characters
chars = list("Hello")
print(chars) # ['H', 'e', 'l', 'l', 'o']
# From tuple/range
nums = list(range(5))
print(nums) # [0, 1, 2, 3, 4]
# From set/dict ? keys
unique = list({1, 2, 2, 3})
print(unique) # [1, 2, 3] (order not guaranteed)
keys = list({"a": 1, "b": 2})
print(keys) # ['a', 'b']
Advanced conversions — iterators, Dask/Polars results, NumPy arrays.
# From generator (consumes it)
gen = (x**2 for x in range(5))
squares = list(gen)
print(squares) # [0, 1, 4, 9, 16]
# From Dask Bag / delayed computation
import dask.bag as db
bag = db.from_sequence(range(10))
result = list(bag.filter(lambda x: x % 2 == 0).map(lambda x: x**2))
print(result) # [0, 4, 16, 36, 64]
# From Polars Series / DataFrame rows
import polars as pl
s = pl.Series([1, 2, 3])
print(list(s)) # [1, 2, 3]
df_pl = pl.DataFrame({"mag": [7.2, 6.8]})
print(list(df_pl["mag"])) # [7.2, 6.8]
Real-world pattern: earthquake data flattening & chunk processing — convert Dask results to lists.
import dask.dataframe as dd
ddf = dd.read_csv('earthquakes/*.csv', blocksize='64MB')
# Get list of strong events (compute only needed columns)
strong_places = list(
ddf[ddf['mag'] >= 7.0]['place'].compute()
)
print(f"Strong quakes in: {strong_places[:5]}...")
# Chunked processing: convert partitions to lists
chunks = ddf.to_delayed()
strong_per_chunk = []
for chunk in chunks:
df_chunk = chunk.compute()
strong = df_chunk[df_chunk['mag'] >= 7.0]
if not strong.empty:
strong_per_chunk.extend(list(strong['place']))
print(f"Total strong places found: {len(strong_per_chunk)}")
Best practices for list() in Python & data workflows. Prefer list comprehensions — [x for x in iterable] — for filtering/mapping; use list() for simple conversion. Modern tip: use Polars df.to_series().to_list() — fast columnar to list; Dask ddf.compute().values.tolist() for full materialization. Use list() to exhaust iterators — list(gen) consumes generator. Add type hints — def to_list(it: Iterable[T]) -> list[T]: return list(it). Avoid list() on large generators — memory explosion; use itertools.islice() or chunking. Use list(dict.keys()) — for ordered keys (Python 3.7+ dicts are ordered). Use list(df.itertuples()) — pandas row iteration as tuples. Use list(ddf.to_delayed()) — Dask partition iteration. Use list(range(n)) — explicit integer list (rarely needed). Use [] — empty list literal (faster than list()). Use list.copy() or lst[:] — shallow copy. Use list.append()/extend() — grow list dynamically. Use list.insert()/pop() — position-based modification. Use list.sort() — in-place sort. Use sorted(list) — new sorted list. Use len(list) — length check. Use x in list — membership (O(n)). Use list(set()) — unique elements (order not preserved). Use list(dict.items()) — key-value pairs. Use list(zip(a, b)) — pairwise combination. Use list(map(func, seq)) — functional mapping. Use list(filter(pred, seq)) — functional filtering. Use list(enumerate(seq)) — indexed pairs. Use list(reversed(seq)) — reversed copy. Use list(itertools.chain(*lists)) — flatten list of lists. Use list(itertools.product(*lists)) — cartesian product.
list() converts any iterable to a list — strings to chars, tuples/ranges to elements, sets/dicts to keys, generators to full lists. In 2026, use for materialization, type normalization, and integrate with pandas/Polars/Dask for data collection and chunk results. Master list(), and you’ll handle sequence conversion cleanly and efficiently in any Python workflow.
Next time you need a mutable list from an iterable — use list(). It’s Python’s cleanest way to say: “Turn this sequence into a list — ready to modify and reuse.”