Please consider clarifying use of unsafe in README example
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 50/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- numpy, rust
- Ambito
- documentation
Direzione di ricerca
Inizia con l’esempio di codice PyO3 in README e analizza il breve blocco unsafe e le firme delle funzioni circostanti. Aggiungi una spiegazione concisa della sicurezza e riferimenti alla documentazione pertinente, chiarendo anche perché non viene utilizzata l’alternativa con un array mutabile. Il lavoro è completato quando l’esempio spiega il proprio uso di unsafe senza aggiungere una lunga discussione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Thanks for providing this amazing library!
The code example given in this project's README file demonstrates the use of PyO3. I guess that it should also serve as a pedagogical model of how PyO3 should be used. After all, this is often going to be the first bit of PyO3-using code that prospective users are going to see.
Now that example features a short unsafe block without any explanation. But the usage of unsafe in Rust code means that the safety of the featured block has been carefully verified and the compiler should trust that.
In practice the usage of unsafe is quite often accompanied by a comment that explains why it is safe. This should certainly be the case in pedagogical code. I think that such a comment would be very helpful here.
Perhaps this particular use of unsafe is obvious to seasoned PyO3 users, but it certainly isn't to newbies for whom this code will often be the first contact with PyO3. Here are some question answers that may come up:
- Why is this particular use of
unsafesafe after all? - Are there any assumptions without which this would no longer be the case?
- The first function of the module takes
PyReadonlyArrayDyn<'py, f64>arguments. It seems that the second function could similarly take aPyReadwriteArrayDyn<'py, f64>argument (which provides a safeas_array_mutmethod), but it takes&Bound<'py, PyArrayDyn<f64>>instead. Is this indeed a choice and what is the reason behind it?
I'm not suggesting that a long discussion of this issue should be added to the README. Probably a short comment and a few pointers into the documentation would be enough.
- Lingua principale
- Rust
- Stelle
- 1.4k
- Fork
- 141
- Merge medio
- 16m
- PR unite (30g)
- 3
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 PyO3/rust-numpy
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
PyO3/rust-numpy#565 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
PyO3/rust-numpy#563 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
PyO3/rust-numpy#557 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
PyO3/rust-numpy#547 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 20/100
PyO3/rust-numpy#535 ·
Tutte le issue di PyO3/rust-numpy
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
state:needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
zed-industries/zed#64680 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
RustPython/RustPython#8802 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
TheLarkInn/aipm#2390 ·