spacepaste

  1.  
  2. Basic types::
  3. int - signed machine size integer
  4. r_uint - unsigned machine size integer
  5. r_long/r_ulong/r_longlong/r_ulonglong - various integers
  6. char - single character (byte)
  7. bytes - immutable array of chars
  8. bytes? - nullable bytes
  9. float - double-sized IEEE floating point
  10. Low level types:
  11. ll.UCHAR
  12. ll.INT
  13. ...
  14. ll.Array(xxx)
  15. ll.Struct(xxx)
  16. ll.GcStruct(xxx)
  17. ll.GcArray(xxx)
  18. Container types::
  19. list(X) - resizable list of X
  20. array(X) - non-resizable list of X
  21. dict(X, Y) - dict of X keys and Y values
  22. tuple(A, B, C) - tuple of 3 items, A, B, C
  23. list?(X) - nullable list, array or dict
  24. Classes::
  25. class A(object):
  26. _rpython_ = """
  27. class foobar.A # <- namespace declaration for type name
  28. a: int
  29. b: list(int)
  30. c: array(int)
  31. """
  32. PBCs::
  33. space = rpython_pbc("space.ObjSpace", space) - registers PBC under the name "space.ObjSpace",
  34. to be used in signatures
  35. Examples of a signature::
  36. @rpython("int -> int")
  37. def f(a):
  38. return a
  39. @rpython("space.ObjSpace, int, float -> bytes")
  40. def f(space, i, f):
  41. return space.str_w(space.newbytes(str(i)))
  42.