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