Improve performance by removing SHA
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- performance
Direzione di ricerca
Inizia in markdown2.py leggendo _hash_html_block_sub e _hash_text e segui il modo in cui le chiavi generate proteggono e ripristinano il contenuto durante la conversione. Esegui il profiling del costo attuale dell’hashing, quindi verifica che qualsiasi sostituzione preservi il comportamento della conversione, eviti collisioni tra le chiavi e migliori le prestazioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The performance could be faster.
When I profile my blog build, about 60% of the time spent in markdown2.py is spent running SHA hashes.
Could you explain the logic of _hash_html_block_sub and _hash_text generally? Why are we even running SHA inside a markdown converter?
It looks like... this is some some of escape mechanism, maybe? Like we generate a key, replace the HTML with the key (so it doesn't look like HTML to some other stage of the parser that should ignore it), do some processing on the outer HTML, and finally replace all the keys with the original HTML?
That could be served just as well by generating a random string rather than a hash, if so?
Ex.
def _hash_text(s: str) -> str:
'md5-' + sha256(SECRET_SALT + s.encode("utf-8")).hexdigest()[32:]
could be replaced by the much faster
hex_digits = "0123456789abcdef"
def _hash_text(s: str) -> str:
'md5-' + ''.join(random.choice(hex_digits) for _ in range(32))
for a quick fix.
(Estimate says this will make markdown conversion 2.5X faster)
- Lingua principale
- Python
- Stelle
- 2.8k
- Fork
- 459
- Merge medio
- 2g 19h
- PR unite (30g)
- 4
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di trentm/python-markdown2
-
Add py.typed marker Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
trentm/python-markdown2#696 ·
-
More XSS's in safe mode Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
trentm/python-markdown2#726 ·
-
Bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
trentm/python-markdown2#707 ·
-
Bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
trentm/python-markdown2#688 · 4 commenti ·
-
Bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
trentm/python-markdown2#679 · 2 commenti ·
Tutte le issue di trentm/python-markdown2
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
browser-use/browser-use#5905 ·
-
type: enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ynput/ayon-python-api#363 ·
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
modelscope/FunASR#3728 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
open-compass/opencompass#2655 ·