Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 23396

Python⇒Speed: The surprising way to save memory with BytesIO

$
0
0

If you need a file-like object that stores bytes in memory in Python, chances are you you’re using Pytho’s built-in io.BytesIO(). And since you’re already using an in-memory object, if your data is big enough you probably should try to save memory when reading that data back out. After all, it’s better not to have two copies of all the data in memory when only one will suffice.

In this article we’ll cover:

  • A quick intro to BytesIO.
  • The memory usage impacts of BytesIO.read().
  • The two alternatives for accessing BytesIO data efficiently, and the tradeoffs between them.
Read more...

Viewing all articles
Browse latest Browse all 23396

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>