Learning Platform
Глоссарий Troubleshooting
Урок 11.05 · 18 мин
Средний
PyodideWASMmicropipbrowser-constraintspure-stdlibNumPyRun-on-Your-Machinepandaspolarspyarrow

Why pandas/Polars/PyArrow don’t run в browser

Студент может удивиться: “Платформа на Pyodide; почему pandas / Polars / PyArrow преподаются conceptually + Run-on-Your-Machine, а не интерактивно как stdlib challenges?” Этот урок объясняет constraint + decision: WASM size limits + C/Rust extension dependencies + micropip experimental status делают full library bundling непрактичным в course-scope. Pure-stdlib challenges (Pattern 4) + Run-on-Your-Machine для real demos — pragmatic compromise.

В этом уроке:

  1. Why this lesson exists — pedagogical контекст.
  2. WASM size constraints — pandas (~50MB), Polars (~30MB), PyArrow (~50MB).
  3. C/Rust extension dependencies — pandas → NumPy → 30+ C extensions.
  4. micropip experimental statusmicropip.install(...) works for some, not all.
  5. What runs в Pyodide today — pure-stdlib + NumPy partial.
  6. Decision: switch к local Python execution — Run-on-Your-Machine recap.
  7. Cross-link M00 урок 03 — Pyodide environment foundation.

Why this lesson exists

Учащиеся приходят в M10 с ожиданиями interactive pandas REPL (как в Jupyter / Colab). Платформа использует Pyodide — браузерный CPython (3.12.x, compiled к WASM). pandas / Polars / PyArrow существуют для Pyodide через micropip — но их использование в course-context имеет несколько барьеров. Этот урок документирует решение учить conceptually + Run-on-Your-Machine для real-engagement.


WASM size constraints

LibraryApprox WASM bundle sizeReason
pandas (with deps)~50MBNumPy + Cython + 30+ C extensions
Polars~30MBRust binary + minimal deps
PyArrow~50MBC++/Rust Arrow core + parquet + ipc + compute kernels
NumPy alone~10MBC/Fortran linear algebra

Сравнение: наш platform Pyodide bundle (/python-course/<lesson> page) — ~5MB Python runtime + lesson MDX (~20-50KB). Загрузка pandas в browser добавляет 50MB к page load — 10x increase. На mobile / slow connections это блокирует initial render.

Trade-off: инструктор может ждать загрузки 50MB ради Jupyter-like experience? Course-design says no для broad accessibility — keep page load fast (~5MB) → Pyodide stdlib challenges.


C/Rust extension dependencies

pandas зависит от:

pandas
├── numpy (C extensions: ndarray, ufunc, linalg)
├── python-dateutil
├── pytz
├── numexpr (optional, C++)
├── bottleneck (optional, C)
└── (множество других optional deps)

Pyodide compiles C extensions к WASM — но build complexity high. Каждое minor pandas / numpy update требует rebuild Pyodide WASM bundles. Pyodide project ships WASM bundles периодически, не sync с upstream. Production rule: assume Pyodide pandas lags upstream pandas by 6-12 months.

Polars — Rust binary; полная rebuild нужна для каждой Polars version. Pyodide Polars bundle exists для некоторых versions, не всех.

PyArrow — C++/Rust core; даже больше build complexity.


micropip experimental status

import micropip
await micropip.install('pandas')  # downloads + installs WASM bundle

Это работает для libraries с pre-built Pyodide WASM bundles. Status (state of the art 2026):

  • Tier 1 (works reliably): numpy, pandas, scikit-learn, matplotlib, requests — Pyodide upstream maintains.
  • Tier 2 (experimental — may break version-to-version): polars, pyarrow — depends на upstream contributors.
  • Tier 3 (unsupported): libraries с heavy C dependencies (e.g., tensorflow, pytorch, lxml).

Course constraint: production-stability important. Tier 2+ — too experimental для course content (versions меняются, learner может загружать lesson через год — micropip install fails). Pure-stdlib (Tier 0) — guaranteed available, stable across Pyodide versions.

Cite Pyodide FAQ — Loading packages + micropip docs.


What runs в Pyodide today (course assumption v2.4)

Pure-stdlib (always available, all versions):

  • io, csv, json, pathlib (M09 challenges Pattern 1/2/3)
  • itertools, collections, statistics, functools, operator (M10 Pattern 4 challenges)
  • dataclasses, enum, inspect, re, typing
  • gzip, bz2, lzma (M09 урок 05 demos)
  • unittest (Phase 67 M08 testing)

NumPy — partial available через pyodide.loadPackage('numpy') или await micropip.install('numpy')opt-in load (~10MB extra). Pyodide upstream maintains. Course не требует NumPy для challenges (хотя могло бы).

Pandas / Polars / PyArrowNOT bundled в course-scope. Available через micropip.install(...) но experimental status + load time не подходит для browser interactive challenges.


Decision: switch к local Python execution

Course strategy для М10 Data Libraries:

  1. Concept lessons (М10 уроки 01-04, 06) — prose + diagrams + cross-course links. Объясняем что и зачем, без runtime в browser.
  2. Pure-stdlib challenges (Pattern 4) — itertools.groupby + statistics.mean ≈ pandas groupby; Counter.most_common ≈ pandas value_counts. Tests algorithm understanding.
  3. Run-on-Your-Machine callouts (≥3 в М10 — уроки 01/02/03) — pip install 'pandas>=2.2,<3.0' + minimal demo + expected output. Tests library API engagement.

Pedagogical principle: library-specific runtime (pd.DataFrame(...), pl.scan_csv(...), pa.Table.from_pylist(...)) — local Python territory. Course taught browser-stdlib для accessibility; library mastery deferred к learner’s own venv (~5 min pip install).


Run-on-Your-Machine convention recap

Total Run-on-Your-Machine callouts через course (Phase 64 → Phase 68):

ModuleCountPurpose
M00 урок 03 (pyodide-env)1First introduction — establishes convention
M07 урок 07 (mypy-bridge)1mypy local install
M08 (testing-pytest, 5 callouts)5pytest local install + actual test runs
M09 урок 06 (pathlib mandate)1real disk operations
M09 урок 07 (summary)1optional full pipeline
М10 уроки 01, 02, 03 (this phase)3pandas / Polars / PyArrow demos (mandatory per SC#6)
Cumulative course-wide12broad pedagogy для local-machine engagement

Convention shape (Pattern 5) — ингредиенты <Callout type="tip"> блока:

  1. Заголовок — bold **Run-on-Your-Machine: <library> <operation>** — convention starts с literal “Run-on-Your-Machine:” prefix (validate-run-on-your-machine.cjs gate в Wave 0).
  2. Установкаpip install '<library>>=<min>,<<max>' (Pitfall 32 — version pin always).
  3. Файл-demo — fenced python code-block с realистичным API usage (rendered as syntax-highlighted text, NOT executed).
  4. Команда run — fenced bash code-block, обычно python3 <demo>.py.
  5. Ожидаемый вывод — fenced text block с expected stdout.
  6. (Optional) — comparison к browser challenge stdlib equivalent (Pattern 4 link).

Реальные примеры — М10 уроки 01 (pandas), 02 (Polars), 03 (PyArrow) выше; М08 уроки 02, 03, 05 (pytest) — Phase 67 baseline.

Pitfall 32 (carrying от Phase 67) — always version-pin в pip install. Без pin — pip install pandas загружает latest, breaking changes возможны (e.g., pandas 3.0 — CoW default).


M00 урок 03 pyodide-env — first encounter с constraints. Promised:

Browser execution = stdlib only. Library mastery → local venv (Run-on-Your-Machine convention to come).

М10 урок 05 (this) — implements promise + recaps decision rationale + bridges к Run-on-Your-Machine pattern.

Three-phase pedagogy:

  1. M00 урок 03 — promise (constraint introduced).
  2. M07/M08/M09 — Run-on-Your-Machine first occurrences (12 cumulative callouts shipped).
  3. M10 урок 05 — synthesis lesson (constraints documented + decision justified).

Что в следующем уроке

М10 урок 06 — Decision matrix — когда выбрать pandas / Polars / PyArrow / DuckDB / Spark / DataFusion. Factor matrix: data size / single-machine vs distributed / lazy API / Arrow interop / language ecosystem. Optional Pattern 4 variant py-m10-06-code-1 (top-K via Counter.most_common).

Проверьте понимание

Результат: 0 из 0
Концептуальный
Вопрос 1 из 4. Почему M10 преподаёт pandas / Polars / PyArrow conceptually + Run-on-Your-Machine, а не interactive в browser?

Закончили урок?

Отметьте его как пройденный, чтобы отслеживать свой прогресс

Войдите чтобы оценить урок

Прогресс модуля
0 из 7