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

Python⇒Speed: float64 to float32: Saving memory without losing precision

$
0
0

Libraries like NumPy and Pandas let you switch data types, which allows you to reduce memory usage. Switching from numpy.float64 (“double-precision” or 64-bit floats) to numpy.float32 (“single-precision” or 32-bit floats) cuts memory usage in half. But it does so at a cost: float32 can only store a much smaller range of numbers, with less precision.

So if you want to save memory, how do you use float32 without distorting your results? Let’s find out!

In particular, we will:

  • Explore some of the limits of the numbers float32 lets you express.
  • Discuss a couple of different ways to solve the problem using basic arithmetic.
  • Suggest a different solution to reducing memory, which gives you an even bigger range than float32.
Read more...

Viewing all articles
Browse latest Browse all 24347

Trending Articles



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