# Add \`take\_bytes(\[n\])\` to \`bytearray\` providing a zero-copy path to \`bytes\`

**URL:** <https://discuss.python.org/t/add-take-bytes-n-to-bytearray-providing-a-zero-copy-path-to-bytes/103804>\
**Category:** Ideas\
**Created:** [September 17, 2025, 8:00pm UTC](https://discuss.python.org/t/add-take-bytes-n-to-bytearray-providing-a-zero-copy-path-to-bytes/103804 "2025-09-17T20:00:15Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![vstinner](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/vstinner/32/15130_2.png) [@vstinner](https://discuss.python.org/u/vstinner)\
**Post date:** [September 25, 2025, 10:47am UTC](https://discuss.python.org/t/add-take-bytes-n-to-bytearray-providing-a-zero-copy-path-to-bytes/103804/5 "2025-09-25T10:47:50Z")

</div>

`bytearray` supports fast deletion at the start and at the end, it avoids resizing the buffer in most cases. Using `bytes` or `PyBytesWriter` inside `bytearray` may lose this optimization, no?

---

_[View the full topic](https://discuss.python.org/t/add-take-bytes-n-to-bytearray-providing-a-zero-copy-path-to-bytes/103804)._
