4.8. Unsupported Types

Before we explore each standard type, we conclude this chapter by giving a list of types that are not supported by Python.

Boolean

Unlike Pascal or Java, Python does not feature the Boolean type. Use integers instead.

char or byte

Python does not have a char or byte type to hold either single character or 8-bit integers. Use strings of length one for characters and integers for 8-bit numbers.

pointer

Since Python manages memory for you, there is no need to access pointer addresses. The closest to an address that you can get in Python is by looking at an object's identity using the id() built-in function. Since you have no control over this value, it's a moot point.

int vs. short vs. long

Python's plain integers are the universal “standard” integer type, obviating the need for three different integer types, i.e., C's int, short, and long. For the record, Python's integers are implemented as C longs. For values larger in magnitude than regular integers (usually your system architecture size, i.e., 32-bit), use Python's long integer.

float vs. double

C has both a single precision float type and double-precision double type. Python's float type is actually a C double. Python does not support a single-precision floating point type because its benefits are outweighed by the overhead required to support two types of floating point types.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset