PEP 554: Issues with data passing and pickle
Nessuno ha ancora preso questa issue.
- Lingua principale
- reStructuredText
- Stelle
- 5k
- Fork
- 1.8k
- Merge medio
- 2g 4h
- PR unite (30g)
- 25
Descrizione
I believe the example program given in PEP 554: https://peps.python.org/pep-0554/#passing-objects-via-pickle has some issues. It's based on a zero value (b'\x00') being a data terminator, but my attempts to recreate this (using threads instead of interpreters) showed that pickle will insert zero values in the middle of the data stream:
Python 3.10.4 (main, May 7 2022, 16:23:10) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> pickle.dumps("PEP 554")
b'\x80\x04\x95\x0b\x00\x00\x00\x00\x00\x00\x00\x8c\x07PEP 554\x94.'
I think the goal here is to simply demonstrate passing pickled objects through the pipe. To that end, it might make a better example to change the reading portion to read a fixed, relatively large, buffer at once and then decode that. Something like:
data = os.read(reader, 1024)
obj = pickle.loads(data)
do_something(obj)
This is clearly not a general purpose solution, but I think for an example like this, not solving all of the corner cases is OK.
Thanks for all of the tremendous work already put into this! This will be very cool!
Guida per i contributori
Apri la guida per i contributori
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.
Direzione di ricerca
Apri la sezione “Passing Objects via Pickle” di PEP 554 ed esamina la logica di lettura dalla pipe e di terminazione dell’esempio. Verifica l’esempio rispetto all’output pickle mostrato, quindi aggiorna l’esempio in modo che il comportamento documentato corrisponda alla dimostrazione prevista e conferma che lo snippet aggiornato possa caricare l’oggetto pickle.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100