Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Speed up array appends

Aberta
#665 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

@harshitgupta31415 já está trabalhando nisso.

Desde 15/10/2026.

  • #666 de @harshitgupta31415 — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
42/100
Tipo de issue
Refatoração
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
data

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
861
Forks
201
Merge médio
3d 19h
PRs com merge (30d)
24

Preparar o ambiente

  • Sem Dockerfile nem arquivo Docker Compose
  • Tem um modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-poetry/tomlkit

Todas as issues de python-poetry/tomlkit

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.