1

I receive an mp3 stream in client1 and then I send it out again to client2 in real time.
I want to create a buffer which would store some data and it would only send it out to client2 when it fills completely. This would help me to avoid deadlocks.

I am not sure how to create such a buffer in python. What data structure can I use and how can I implement it? Any hints?

4

1 回答 1

0

我认为惯用和 pythonic 的方法之一是使用 alist.append()每个缓冲区元素/字符串到列表中。当我完成并且我想要整个缓冲区时,我会"".join(buffer_list)得到整个shebang。它像 StringBuilder 一样工作

您还可以查看StringIOC 扩展版本。

这个页面有很多关于这个主题的信息:Python中的高效字符串连接

于 2012-12-03T21:40:17.530 回答