QuantEcon / QuantEcon/QuantEcon.py

ENH: Slim the mandatory dependency set: sympy and requests

Open
#880 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
2.4k
Forks
2.3k
Avg merge
3d 3h
Merged PRs (30d)
3

Description

Problem

Two of our five runtime dependencies serve one peripheral call site each, and both imports are already function-local:

  • sympy (heavy; pulls mpmath, roughly 40 MB) is imported once, lazily, at quad.py:171, to run sym.primerange(0, 7920) — the first 1,000 primes for Weyl/Haber equidistributed sequences in qnwequi, and only when the caller didn't pass equidist_pp.
  • requests serves only util/notebooks.py::fetch_nb_dependencies, the notebook support-file downloader.

Every pip install quantecon pays both costs; neither touches the numerical core. Because the imports are already lazy, moving them behind extras is close to mechanical.

Proposed change
  • sympy: replace the call with a ~10-line sieve or a hardcoded constant array (the primes are fixed; regression-test the first/last values against the sympy output) and drop the dependency entirely. Fallback option: an extras group quantecon[quad] with a clear ImportError message.
  • requests: move to an extras group (quantecon[notebooks]) with a lazy import and actionable error — or, if fetch_nb_dependencies has no remaining constituency, fold its retirement into the #786 utility-deprecation conversation (weigh the open fix issue for that function first).
Acceptance criteria
  • Fresh-venv pip install quantecon no longer installs sympy (and, per decision, requests); import quantecon and the full suite green in that venv
  • qnwequi output unchanged (regression test on default equidist_pp)
  • Changelog notes the lighter footprint and any new extras

From the July 2026 technical-debt audit (AI-assisted; claims verified against 28d4b3b on 2026-07-25).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the lazy import and prime generation at quad.py:171, then inspect util/notebooks.py::fetch_nb_dependencies and the open #786 utility-deprecation discussion before choosing the requests path. Verify the packaging metadata and run a fresh-venv install, the full suite, and qnwequi regression coverage; done means the unnecessary runtime dependencies are absent or isolated in documented extras and the changelog is updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.