Quantcast
Channel: Optimization - how to store "bits" in memory? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Optimization - how to store "bits" in memory?

$
0
0

I'm a newbie in Python and I have a problem with storing information. I've got a task from my 'mentor' and I don't know how to do that.I have array with numbers 0 and 1, e.g.

a=[1,1,1,0] 

I know that's integers, but he told I should keep it as bits. I was trying to convert my variable to number e.g:

a = 14 and then ab = bin(14).

But when I'm using sys.getsizeof() ab is bigger than a.I was trying to use bytearray() but I don't understand it, too.I was thinking that I know how a computer works, but that makes me confused.

How should I keep bits? What should I use? What should I read to understand it? and how to measure how big is my variable (sys.getsizeof() is okay for that? Or should I write it to a binary file?).We doing it to optimize memory.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

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