Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Speed up array appends

Aperta
#665 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@harshitgupta31415 ci sta già lavorando.

Dal 15/10/2026.

  • #666 di @harshitgupta31415 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Start from the array append path that tomlkit.dumps reaches when a Python list is converted, and find where the index is rebuilt for every existing item. Time the 3000-item example before changing anything. Done means that a normal append only indexes the new item, middle inserts and special formatting items still rebuild, and the output text and existing tests stay the same.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Adding an item to the end of an array rebuilds the index for every item already in it. So when an array is built one item at a time, the same entries get checked over and over.

This also happens when writing a Python list with tomlkit.dumps, not just when calling append directly. It can add up when writing a long file list or dependency list.

For example, this goes through the repeated append path:

import tomlkit

files = [f"src/package/module_{n}.py" for n in range(3000)]
text = tomlkit.dumps({"files": files})

For a normal append, the old items haven't moved. Could we keep their indexes and add only the new one? Middle inserts and the special formatting items can keep the current rebuild.

For N normal appends, that would bring the index work from O(N²) to O(N), without adding another cache. Converting the values and writing the TOML would still take their own time.

Lingua principale
Python
Stelle
862
Fork
193
Merge medio
4g 2h
PR unite (30g)
25

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-poetry/tomlkit

Tutte le issue di python-poetry/tomlkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.