native_operations.rst 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Miscellaneous native operations
  2. ===============================
  3. This is a list of various non-type-specific operations that have
  4. custom native implementations. If an operation has no native
  5. implementation, mypyc will use fallback generic implementations that
  6. are often not as fast.
  7. .. note::
  8. Operations specific to various primitive types are described
  9. in the following sections.
  10. Operators
  11. ---------
  12. * ``x is y`` (this is very fast for all types)
  13. Functions
  14. ---------
  15. * ``isinstance(obj, type: type)``
  16. * ``isinstance(obj, type: tuple)``
  17. * ``cast(<type>, obj)``
  18. * ``type(obj)``
  19. * ``len(obj)``
  20. * ``abs(obj)``
  21. * ``id(obj)``
  22. * ``iter(obj)``
  23. * ``next(iter: Iterator)``
  24. * ``hash(obj)``
  25. * ``getattr(obj, attr)``
  26. * ``getattr(obj, attr, default)``
  27. * ``setattr(obj, attr, value)``
  28. * ``hasattr(obj, attr)``
  29. * ``delattr(obj, name)``
  30. * ``slice(start, stop, step)``
  31. * ``globals()``
  32. Method decorators
  33. -----------------
  34. * ``@property``
  35. * ``@staticmethod``
  36. * ``@classmethod``
  37. * ``@abc.abstractmethod``
  38. Statements
  39. ----------
  40. These variants of statements have custom implementations:
  41. * ``for ... in seq:`` (for loop over a sequence)
  42. * ``for ... in enumerate(...):``
  43. * ``for ... in zip(...):``