# \`Bigstringaf\` and \`Core.Bytes\`: performance and when to use each?

**URL:** <https://discuss.ocaml.org/t/bigstringaf-and-core-bytes-performance-and-when-to-use-each/14538>\
**Category:** Learning\
**Tags:** bytes\
**Created:** [April 22, 2024, 8:40pm UTC](https://discuss.ocaml.org/t/bigstringaf-and-core-bytes-performance-and-when-to-use-each/14538 "2024-04-22T20:40:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andunie](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/andunie/32/5227_2.png) [@andunie](https://discuss.ocaml.org/u/andunie)\
**Post date:** [April 22, 2024, 8:40pm UTC](https://discuss.ocaml.org/t/bigstringaf-and-core-bytes-performance-and-when-to-use-each/14538/1 "2024-04-22T20:40:35Z")

</div>

[Bigstringaf](https://github.com/inhabitedtype/bigstringaf) has some claims about being super fast (and apparently achieves a lot of that through the use of “unsafe” calls). Some libraries, like [lmdb](https://github.com/Drup/ocaml-lmdb), rely heavily on it, so that makes me think it might be close to the consensus choice for raw byte operations – but this might be just me not having a good grasp of the ecosystem.

Meanwhile, [Core.Bytes](https://ocaml.org/p/core/latest/doc/Core/Bytes/index.html) has a very similar API that also does “unsafe” stuff but does so without requiring a specialized type so it feels like it should be much more interoperable and useful – but I may be missing something.

I’ve read somewhere that allocating “bytes” may not require a call to `malloc` while allocating a “bigstring” does so `Bytes` should be preferred for smaller operations, but I’m not sure this is true or where else would the allocation be happening if not through `malloc` or what I am missing.

Anyway, the question is simple: which one is faster?
