Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

Commonmark migration
Source Link

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data directly; they must be encode-ed explicitly with a specific encoding.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data directly; they must be encode-ed explicitly with a specific encoding.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data directly; they must be encode-ed explicitly with a specific encoding.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

added 71 characters in body
Source Link
ShadowRanger
  • 157.9k
  • 12
  • 222
  • 318

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data directly; they must be encode-ed explicitly with a specific encoding.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data directly; they must be encode-ed explicitly with a specific encoding.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

Source Link
ShadowRanger
  • 157.9k
  • 12
  • 222
  • 318

Anything that logically stores a sequence of bytes qualifies. That includes the actual bytes type, bytearray, mmap.mmap, array.array('B'), etc. str in Python 3 is a text type; the characters aren't stored in a specified encoding, so you can't use them as raw binary data.

For the technical definition, see the Python 3 glossary:

An object that supports the Buffer Protocol and can export a C-contiguous buffer. This includes all bytes, bytearray, and array.array objects, as well as many common memoryview objects. Bytes-like objects can be used for various operations that work with binary data; these include compression, saving to a binary file, and sending over a socket.

Some operations need the binary data to be mutable. The documentation often refers to these as "read-write bytes-like objects". Example mutable buffer objects include bytearray and a memoryview of a bytearray. Other operations require the binary data to be stored in immutable objects ("read-only bytes-like objects"); examples of these include bytes and a memoryview of a bytes object.

lang-py

AltStyle によって変換されたページ (->オリジナル) /