š The two `needs-before-*` events hand Sphinx the whole needs dict, which Sphinx 9.1 `repr`s on every emit (0.9 s and 141 MB each)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- build-system, performance
Research direction
Start at the two emit calls in packages/sphinx-needs/src/sphinx_needs/directives/need.py (around lines 376 and 390), which pass the whole needs dict to needs-before-post-processing and needs-before-sealing. Then find the listeners that mutate that dict, since any handle you introduce must still expose it as a mutable mapping. Done when the build no longer calls repr on the 20k-need dict and those listeners behave the same, with the upstream Sphinx repr issue filed separately.
Written by the indexing model from the issue text.
Description
Measured at master 3210ac5c with Sphinx 9.1.0 (2026-10-14), loading ubCode's 20 847-need export through needs_external_needs: repr((needs,)) of the needs dict takes 0.93 s and produces a 141 MB string, and the build pays it twice.
EventManager.emit in Sphinx 9.1 calls repr(args) unconditionally for a debug log line (sphinx/events.py:428-435), and sphinx-needs passes the whole needs dict as the event argument of needs-before-post-processing and needs-before-sealing (packages/sphinx-needs/src/sphinx_needs/directives/need.py:376 and :390). cProfile: builtins.repr from sphinx/events.py 3.0 s profiled, 41 694 NeedItem.__repr__ calls (2 Ć 20 847). About 9 % of a 21.8 s build, for a debug line nobody reads.
Two fixes, which compose: pass a lightweight handle (an object whose __repr__ is a one-liner and which still gives listeners the mutable mapping), and report the unconditional repr upstream to Sphinx, since every extension that emits a large argument pays the same.
- Dominant language
- Python
- Stars
- 309
- Forks
- 103
- Avg merge
- 10h 41m
- Merged PRs (30d)
- 128
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up ā it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from useblocks/sphinx-needs
-
documentation pkg: sphinx-needs
Difficulty 1/5 Under an hour Newbie friendliness 82/100
useblocks/sphinx-needs#2255 Ā·
Maintainers usually reply within 1 day
-
bug pkg: sphinx-needs
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
useblocks/sphinx-needs#2253 Ā·
Maintainers usually reply within 1 day
-
bug pkg: sphinx-needs
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
useblocks/sphinx-needs#2251 Ā·
Maintainers usually reply within 1 day
-
bug pkg: sphinx-needs
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
useblocks/sphinx-needs#2249 Ā·
Maintainers usually reply within 1 day
-
documentation pkg: sphinx-test-reports
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
useblocks/sphinx-needs#2247 Ā·
Maintainers usually reply within 1 day
All issues in useblocks/sphinx-needs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
huggingface/sentence-transformers#4186 Ā·
Maintainers usually reply within 5 days
-
documentation good first issue
Difficulty 2/5 Half a day Newbie friendliness 72/100
sujithputta02/Esapay#13 Ā·
-
bot-triaged module: correctness (silent) module: mps module: NaNs and Infs triage review
Difficulty 2/5 Half a day Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SCIInstitute/SCIRun#2842 Ā·
Maintainers usually reply within 3 days