理解Python中的RingBuffer环形缓冲区

  • ringbuffer

    Refered from Wikipedia, a ring buffer(环形缓冲区 or circular buffer, circular queue, cyclic buffer) is a data strcture that uses a single, fixed-size buffer as if it were connected end-to-end.

    This structure lends itself easily to buffering data streams.

  • buffer

    First, we should know what the “BUFFER” is in computer science.

    According Wikipedia, a data buffer (or just buffer) is a region of a physical memory storage used to temporarily store data while it is being moved from one place to another.

    Typically, the data is stored in a buffer as it is retrieved from an input device or just befor it is sent to an output device.

    However, a buffer may be used when moving data between processes within a computer.

  • LMAX Disruptor 中 ringbuffer

    LMAX是伦敦多元资产交易所的简称,https://www.lmax.com/

    其开源的LMAX Disruptor可以处理数百万订单/秒。ringbuffer是其一大利器。

    ringbuffer用于在不同上下文(线程)间传递数据的buffer。

    ringbuffer是数据(数组内元素的内存地址是连续性存储的)比链表快。

  • Python中实现ringbuffer

    网上相关资料不多。

    1. 自己实现

      refer from

      class RingBuffer:
          def __init__(self, size):
              self.data = [None for i in range(size)]
          
          def append(self, x
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值