concept byte in category python

appears as: byte, A byte, bytes, bytes
Hello World! Third Edition

This is an excerpt from Manning's book Hello World! Third Edition.

Two hundred and fifty-six is the number of different values you can make with 8 bits. That’s all the possible combinations of eight 1s and 0s. Eight bits is also called a byte, and a byte is the smallest chunk of memory that has its own address. An address is the computer’s way of finding particular pieces of memory.

It’s like on your street. Your house or apartment has an address, but your room doesn’t have its own address. A house is the smallest “addressable unit” on the street. A byte is the smallest “addressable unit” in your computer’s memory.

They could have used more than 8 bits for each color, but the next amount that makes sense would be 16 bits (2 bytes), because it’s not very convenient to use only part of a byte. And it turns out that, because of the way the human eye sees color, 8 bits is enough to make realistic-looking colors.

What’s the difference between text and bytes?

In most of the programs we’ve written so far, we’ve worked with strings of text: letters, numbers, punctuation, and spaces. But computers don’t really think in terms of letters; they store things in memory as binary numbers. So people came up with ways to represent text as binary bytes. (Remember that a byte is just a group of eight binary digits.)

Unfortunately, programmers spent a long time arguing over which way was best. So there are many different character encodings you can use to convert between text and bytes. Different networking protocols specify different encodings to use, so when you send text over a socket in Python (as bytes), you have to tell it which encoding you want. You can do this by calling the encode() method on a string and passing in the name of the encoding. (In this book, we’ll always use UTF-8, which is the most popular encoding today.)

Natural Language Processing in Action: Understanding, analyzing, and generating text with Python

This is an excerpt from Manning's book Natural Language Processing in Action: Understanding, analyzing, and generating text with Python.

Bytes (bytes) are arrays of 8-bit values, usually used to hold ASCII characters or Extended ASCII characters (with integer ord values greater than 128).[1] Bytes are also sometimes used to store RAW images, WAV audio files, or other binary data blobs.

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest