# AMQP Types

These tables summarize the various AMQP types and their Python API equivalents as used in the API.

## Scalar Types

AMQP Type | Proton C API Type | Proton Python API Type | Description
--- | --- | --- | ---
null | PN_NONE | `None` | Indicates an empty value.
boolean | PN_BOOL | `bool` | Represents a true or false value.
ubyte | PN_UBYTE | `proton.ubyte` | Integer in the range \(0\) to \(2^8 - 1\) inclusive.
byte | PN_BYTE | `proton.byte` | Integer in the range \(-(2^7)\) to \(2^7 - 1\) inclusive.
ushort | PN_USHORT | `proton.ushort` | Integer in the range \(0\) to \(2^{16} - 1\) inclusive.
short | PN_SHORT | `proton.short` | Integer in the range \(-(2^{15})\) to \(2^{15} - 1\) inclusive.
uint | PN_UINT | `proton.uint` | Integer in the range \(0\) to \(2^{32} - 1\) inclusive.
int | PN_INT | `proton.int32` | Integer in the range \(-(2^{31})\) to \(2^{31} - 1\) inclusive.
char | PN_CHAR | `proton.char` | A single Unicode character.
ulong | PN_ULONG | `proton.ulong` | Integer in the range \(0\) to \(2^{64} - 1\) inclusive.
long | PN_LONG | `int` or `long` | Integer in the range \(-(2^{63})\) to \(2^{63} - 1\) inclusive.
timestamp | PN_TIMESTAMP | `proton.timestamp` | An absolute point in time with millisecond precision.
float | PN_FLOAT | `proton.float32` | 32-bit floating point number (IEEE 754-2008 binary32).
double | PN_DOUBLE | `double` | 64-bit floating point number (IEEE 754-2008 binary64).
decimal32 | PN_DECIMAL32 | `proton.decimal32` | 32-bit decimal number (IEEE 754-2008 decimal32).
decimal64 | PN_DECIMAL64 | `proton.decimal64` | 64-bit decimal number (IEEE 754-2008 decimal64).
decimal128 | PN_DECIMAL128 | `proton.decimal128` | 128-bit decimal number (IEEE 754-2008 decimal128).
uuid | PN_UUID | `uuid.UUID` | A universally unique identifier as defined by RFC-4122 section 4.1.2.
binary | PN_BINARY | `bytes` | A sequence of octets.
string | PN_STRING | `str` | A sequence of Unicode characters.
symbol | PN_SYMBOL | `proton.symbol` | Symbolic values from a constrained domain.

## Compound Types

AMQP Type | Proton C API Type | Proton Python API Type | Description
--- | --- | --- | ---
array | PN_ARRAY | `proton.Array` | A sequence of values of a single type.
list | PN_LIST | `list` | A sequence of polymorphic values.
map | PN_MAP | `dict` | A polymorphic mapping from distinct keys to values.

## Specialized Types

The following classes implement specialized or restricted types to help enforce type restrictions in the AMQP specification.

Proton Python API Type | Description | Where used in API
--- | --- | ---
`proton.SymbolList` | A `list` that only accepts `proton.symbol` elements. However, will silently convert strings to symbols. | `proton.Connection.desired_capabilities` `proton.Connection.offered_capabilities`
`proton.PropertyDict` | A `dict` that only accppts `proton.symbol` keys. However, will silently convert strings to symbols. | `proton.Connection.properties`
`proton.AnnotationDict` | A `dict` that only accppts `proton.symbol` or `proton.ulong` keys. However, will silently convert strings to symbols. | `proton.Message.annotations` `proton.Message.instructions`

These types would typically be used where the the above attributes are set. They will silently convert strings to symbols, but will raise an error if a not-allowed type is used. For example:

    >>> from proton import symbol, ulong, Message, AnnotationDict
    >>> msg = Message()
    >>> msg.annotations = AnnotationDict({'one':1, symbol('two'):2, ulong(3):'three'})
    >>> msg.annotations
    AnnotationDict({symbol('one'): 1, symbol('two'): 2, ulong(3): 'three'})
    >>> m.instructions = AnnotationDict({'one':1, symbol('two'):2, ulong(3):'three', 4:'four'})
      ...
    KeyError: "invalid non-symbol key: <class 'int'>: 4"
    >>> m.instructions
    >>>