Cost of cloning a stream #578
-
Say you register a callback for sending to a stream, that will potentially be called a lot of times. The stream would need to be cloned, right? def synchronous_callback(send_stream: MemoryObjectSendStream) -> None:
cloned = send_stream.clone()
with cloned:
cloned.send_nowait('hello') I was wondering if cloning is expensive in terms of CPU, or negligible? |
Beta Was this translation helpful? Give feedback.
Answered by
agronholm
Jun 8, 2023
Replies: 1 comment 5 replies
-
The cost is negligible. Memory object streams are supposed to be closed eagerly when they're no longer needed. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
davidbrochart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The cost is negligible. Memory object streams are supposed to be closed eagerly when they're no longer needed.