20170915

Numpy scalar types cheat-sheet (x86-64)

Saving this as note-to-self; The Numpy documentation is thorough but unfriendly for rapid scanning. Here's a cheat-sheet for Linux x86-64.

  • (BHIL) bhil : (u)int-8,16,32,64
  • efdg : float-16,32,64,80
  • FDG : complex 2×(32,64,80)
  • ? : Boolean
  • S# / U# : Length-# byte/Unicode strings
  • On Intel x86-64 the signed/unsigned pointer-length types intp p / uintp P are int64 / uint64 , as are longlong q / ulonglong Q .
  • All types are little-endian < by default (prefix > to specify big-endian)
  • Types can be suffixed by an integer to specify vector-types 

You have unsigned Bytes, sHorts, Integers, and Longs (lower-case bhil for signed); There's floats, doubles, and giant-floats; Half-floats e come before f and are great for saving data. The upper-case FEG are complex types (twice as big). Booleans ? what? Byte Strings and Unicode strings are nice. You may see datetiMe64 and tim edelta in dataframes. Use object when you can't be bothered with typing, and don't worry about Void.

Type aliases

  • int8 byte b
  • int16 short h
  • int32 intc i
  • int64 int_ l
  • uint8 ubyte B
  • uint16 ushort H
  • uint32 uintc I
  • uint64 uint L
  • float16 half e
  • float32 single f
  • float64 float_ double d
  • float128 longfloat longdouble g (actually 80 bit)
  • complex64 csingle singlecomplex F
  • complex128 complex_ cfloat cdouble D
  • complex256 clongdouble longcomplex clongfloat G (actually 2×80 bit)
  • bool8 bool_ ?
  • datetime64 M
  • timedelta64 m
  • object_ o
  • string_ bytes_ S
  • unicode_ str_ U
  • void V

  • ulonglong Q is uint64

  • longlong q is int64
  • intp p is int64
  • uintp P is uint64

No comments:

Post a Comment