Motivation behind not being able to get IO's content, and IO-wrapped interfacing with unwrapped (normal) code
還沒有人認領這個 Issue。
評估
研究方向
從 issue 中提到的文件和 IO 相關進入點開始,尤其是 unsafe_perform_io,以及包裝的 Python 程式碼與標準 Python 程式碼之間的區別。釐清隱藏 IO 內容的理由,並記錄 IO 包裝操作與一般 Python 程式碼之間受支援的界線。
由索引模型根據 Issue 內容生成。
描述
Hi! Question(s) on IO.
I am trying to write a little wrapper for some stateful operation (imagine I have to do IO from/to a file), and I found out that IO containers are designed to hide their content. It's impossible to get the value of, say, a successful read result (nothing like IOSuccess.unwrap()), unless one uses unsafe_perform_io.
What is the rationale behind this design? I am asking because I am not familiar with writing typed functional code, and I could not find a motivation in the documentation for why it shouldn't be possible to get the raw content of an IO container.
Second question related to interface between IO-wrapped code and normal "unsafe" code:
Let's say I am writing code A where want to mark and wrap all IO operations. Now, code A has to interface with standard python code B. What choices do I have to make them talk?
Do I have to unwrap all my operations with unsafe_perform_io, in case I want to do something simple like getting a string from my wrapped code? Do I have to rewrite code B by making it all safe and IO-wrapped, so that they can communicate with no "unsafe" bridge between them?
It seems that in such scenario I would end up with code pieces that are of "different colors" - using the usual async-vs-sync metaphore of incompatible red and blue code -, and I would be forced to make everything of the same color.
(Here "red code" = "python code written in railway style" and "blue code" = "standard procedural python code").
- 主要語言
- Python
- 星號
- 4.4k
- 分支
- 154
- 平均合併
- 3 小時 5 分鐘
- 30 天內合併 PR
- 22
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
dry-python/returns 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 48/100
dry-python/returns#2394 · 1 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 52/100
dry-python/returns#2365 ·
-
難度 5/5 一週以上 新手友好度 25/100
dry-python/returns#2355 · 1 則留言 ·
-
bug
難度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2295 · 4 則留言 · 1 個 reaction ·
-
bug
難度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2253 · 2 則留言 ·
查看 dry-python/returns 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
難度 1/5 1 小時以內 新手友好度 90/100
-
難度 2/5 1-3 小時 新手友好度 70/100
huggingface/Repo2RLEnv#163 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
難度 2/5 1-3 小時 新手友好度 70/100
NousResearch/hermes-agent#121143 ·