You can use Python's struct module to convert the byte string to integers. It takes care of endianness and sign extension for you. I guess you are trying to interpret this 16-byte string as 8 2-byte signed integers, in big-endian byte order. The format string for this is '>8h. The > character tells Python to interpret the string as big endian, 8 means 8 of the following data type, and h means signed short integers.

import struct
nums = struct.unpack('>8h', bin_bytes)

Now nums is a tuple of integers that you can process further.

I'm not quite sure if your data is little or big endian. If it is little-endian, you can use < to indicate that in the struct.unpack format string.

Answer from mtrw on Stack Overflow
🌐
Real Python
realpython.com › python-bytes
Bytes Objects: Handling Binary Data in Python – Real Python
March 5, 2025 - Despite not having an explicit sign bit in their internal representations, the numeric types in Python are indeed signed. At the same time—as if that weren’t confusing enough—Python can only represent unsigned bytes with its bytes data type.
Discussions

python - How to convert bytes byte by byte to signed int - Stack Overflow
I have a bytes element. My word size is 1, a single byte. The contents can be b'\xff\xff\x01' meaning [-1, -1, 1]. I want to convert it to the int representation from the bytes form. Logically my a... More on stackoverflow.com
🌐 stackoverflow.com
language design - Should bytes be signed? - Programming Language Design and Implementation Stack Exchange
The question "should bytes be signed?" isn't really a meaningful language design question. Generally speaking, we don't start by deciding what names we're going to have and then figure out what those names should refer to. Instead, we start by deciding what things we're going to have, and then we figure out what those things should be named. ... The answers to questions 1 and 2 depend on what your goals are. At one extreme, Python ... More on langdev.stackexchange.com
🌐 langdev.stackexchange.com
December 9, 2023
Python - convert signed int to bytes - Stack Overflow
error messgae is clear , if your vaue includes signs you need to pass signed =True when you convert it to bytes: More on stackoverflow.com
🌐 stackoverflow.com
python - Using signed Bytes with GDAL - Geographic Information Systems Stack Exchange
In the list of raster pixel data types that are available with GDAL, the "smallest" types are Bytes, UInt16 and Int16. I would like to store integers from 0 to 100 in the smallest image type, but w... More on gis.stackexchange.com
🌐 gis.stackexchange.com
January 23, 2018
🌐
Python
docs.python.org › 3 › builtins › stdtypes.html
Built-in Types — Python 3.14.7 documentation
If signed is False and a negative integer is given, an OverflowError is raised. The default value for signed is False. The default values can be used to conveniently turn an integer into a single byte object:
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to convert python byte array to signed int
5 Best Ways to Convert Python Byte Array to Signed Int - Be on the Right Side of Change
February 24, 2024 - This one-liner typecasts the byte array to a signed short directly using Python’s memoryview cast function, retrieving the value with index zero.
Top answer
1 of 9
49

Frame Challenge: Bytes should not be integers.

Bytes are bytes, a fixed-size sequence of bits, typically 8 on modern computers.

Should an array of bits be signed or unsigned? Neither, the question is nonsensical: an array cannot be signed or unsigned in the first place.

There's a long-standing tradition in programming languages to conflate integers and array of bits, which can be seen in that bit-wise operations are typically defined on integers. I argue that this "blending" of the two roles is a mistake: a violation of the Single Responsibility Principle.

Yes, it's all registers at the end... should a pointer be signed or unsigned? Surely nowadays the question seems nonsensical, even though in B pointers and integers were the same type, and in CPU they are manipulated through the same registers.

Just like pointers are different from integers, I hereby argue that array of bits should be different from integers, and bit-wise functions are only sensible on array of bits.

The conversion between integer and array of bits (of the same number of bits) should exist -- just like that between floating point or decimal an array of bits -- and it should ideally boil down to a no-op, but from a type system, the two should be separate.

2 of 9
20

Bytes should be unsigned

There are a few reasons most languages have unsigned bytes by default:

  • A more useful range. Bytes can only represent 256 different numbers so using them effectively is extra important. It is more common to want to represent a bigger number like 200 than -1, so the 0-255 is more practical than -128-127.

This isn't really an issue for bigger numbers that usually default to signed. Even an signed short can go up to more than 30,000 which is not something you would typically count to.

  • Bytes are most often used as a sequence, rather than as an actual number. You rarely use a type like a byte to store numbers intended as numbers, more often they represent bits of binary data, characters etc.

The "numeric properties" only get in the way of accessing the raw data. Adding a special meaning to the upper half of the byte space would just add extra complexity to any serialization, parsing, string manipulation, etc. code that may want to operate on byte sequences.

🌐
GeeksforGeeks
geeksforgeeks.org › how-to-convert-bytes-to-int-in-python
How to Convert Bytes to Int in Python? - GeeksforGeeks
March 8, 2025 - Signed integer (b'\xfc\x00'): Interpreting the bytes as a signed integer gives -1024. Here, 0xfc represents a negative number in two's complement (a representation for signed integers). ... The struct.unpack() function is part of Python's struct module.
Find elsewhere
🌐
YouTube
youtube.com › watch
3-9-3 Bytes (unsigned, signed integer ) with Python - YouTube
AboutPressCopyrightContact usCreatorsAdvertiseDevelopersTermsPrivacyPolicy & SafetyHow YouTube worksTest new featuresNFL Sunday Ticket · © 2025 Google LLC
Published: February 8, 2024
🌐
YouTube
youtube.com › watch
How to Convert Bytes to Signed Integer in Python - YouTube
Discover how to effectively convert bytes to signed int in Python using simple methods, including Python's built-in capabilities and Numpy.---This video is b...
Published: April 14, 2025
Views: 0
🌐
Taylorvananne
taylorvananne.com › blog › post › representing-signed-ints-as-bytes-in-python
Representing Signed Ints as Bytes in Python // Taylor Van Anne
TL/DR: Python doesn’t let you explicitly create signed integers, but the int.to_bytes() method allows you to specify a boolean unsigned argument.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-convert-bytes-to-int-in-python
How to Convert Bytes to Int in Python?
March 27, 2026 - The int.from_bytes() method is the most straightforward way to convert bytes to integers in Python. Remember to specify the correct byte order and use the signed parameter when dealing with signed integers.
🌐
Python
docs.python.org › 3 › library › struct.html
struct — Interpret bytes as packed binary data
The byte order character '=' chooses to use little- or big-endian ordering based on the host system. The struct module does not interpret this as native ordering, so the 'P' format is not available. The IEEE 754 binary16 “half precision” type was introduced in the 2008 revision of the IEEE 754 standard. It has a sign bit, a 5-bit exponent and 11-bit precision (with 10 bits explicitly stored), and can represent numbers between approximately 6.1e-05 and 6.5e+04 at full precision.