Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

šŸ› 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)

Open
#2,250 0 comments 0 reactions 0 assignees View on GitHub

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

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

bug pkg: sphinx-needs

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

  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.

More from useblocks/sphinx-needs

All issues in useblocks/sphinx-needs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.