👌 A `needs_defaults_removed` file costs a full field conversion for every restored default (140 per record on a 20k-need import)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- performance
Research direction
Start with FieldSchema.convert_or_type_check at needs_schema.py:471 and the generate_need default step, then trace how the needs_external_needs reader restores defaults under ub_needs_exchange. Check records(apply_schema_defaults=False) and decide between the two approaches the issue offers. Done means restored defaults no longer hit convert_or_type_check, and the call count for a needs_defaults_removed import drops from about 140 per need, with existing schema-default tests still passing.
Written by the indexing model from the issue text.
Description
When a needs.json was written with needs_json_remove_defaults = True, the reader restores every schema default into every record (ub_needs_exchange, contract §7) and generate_need then converts every restored value through FieldSchema.convert_or_type_check as if it had been authored.
Measured at master 3210ac5c (2026-10-14), loading ubCode's 20 847-need export (138 extra fields + 54 link types in its needs_schema, needs_defaults_removed: true) through needs_external_needs: 2 926 187 convert_or_type_check calls, about 140 per need, 6.6 s profiled (needs_schema.py:471; convert_directive_option 2 884 493 calls, 5.5 s), inside a 21.8 s build. A default has already passed the schema when it was declared, so converting it again per record buys nothing.
Proposal: ask the reader for the records without the defaults (records(apply_schema_defaults=False) exists) and let generate_need's own default step fill them, or mark restored defaults so the conversion is skipped.
- 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 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
UKGovernmentBEIS/control-arena#917 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
debpalash/VoiceStudio#2937 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws-samples/sample-per-model-bedrock#261 ·
Maintainers usually reply within 1 day