Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Speed up array appends

Ouverte
#665 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@harshitgupta31415 y travaille déjà.

Depuis le 15/10/2026.

  • #666 par @harshitgupta31415 — ouverte

Évaluation

Difficulté
4/5
Temps estimé
1-2 jours
Accessibilité débutants
42/100
Type d'issue
Refactorisation
Clarté
Plutôt claire
Activité
Active
Stack technique
python
Domaine
data

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
862
Forks
193
Merge moyen
4 j 2 h
PR mergées (30 j)
25

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de python-poetry/tomlkit

Toutes les issues de python-poetry/tomlkit

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.