python-trio / python-trio/trio
Should we replace send/receive with some other verbs?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
Splitting this discussion off from #796, and specifically the subthread starting here
@njsmith:
On another note: as I write
receive_exactlyandreceive_untiland receive receive receive, I'm somewhat regretting the decision to name our primitivessend/receive. I do like the emphasis that these are active transfers "in the moment", versusread/writethat refer to modifying passive media – and also it's good to avoid associations with Python's conventions aroundread, which are really inappropriate forStreams and forChannels, for different reasons. Butreceiveis just an awkward word: kinda long, annoying to spell. I'd be tempted byget/put, except then we'd haveStream.get_someand that seems like a bad idea.give/take?put/take?put_all/get_any? Or just stick withsend/receive... Maybe this should be a separate issue.
@smurfix:
WRT put/get: Umm … thinking about it, put/get works for single messages, while send/receive makes more sense for byte/character streams. This is because I associate put/get with things like channels or queues that you can use to put some single thing in on one end and get it out the other end.
send/receiveon the other hand is for bytestreams and similar where the focus of these methods is on partitioning the stream into semantic chunks.Calling
receive_exactlyon four bytes (and then N bytes) to de-partition a byte-encoded message > stream makes sense.
Callingget_exactlyto read N HTTP requests or MQTT messages? not so much.Yes,
receiveis awkward. So … userecvinstead?
@njsmith:
thinking about it, put/get works for single messages, while send/receive makes more sense for byte/character streams. This is because I associate put/get with things like channels or queues that you can use to put some single thing in on one end and get it out the other end.
That's why I find them attractive :-). For single objects we currently have
Channel.sendandChannel.receive, and for byte streams we haveStream.send_allandStream.receive_some. So in all cases, the verb on its own is being used to refer to single objects, and then sometimes we have a modifier to make it plural.And
get_exactlywould take aStreamspecifically, not aChannel, so I don't think there'd be any confusion about using it for MQTT.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review issue #796 and the subthread linked in this issue, then compare the existing Channel.send/receive and Stream.send_all/receive_some naming. The work is complete when the project has a decided, consistent replacement or rationale for retaining the current verbs across these APIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100