Deferred Execution#

Most Xorbits objects, including Xorbits DataFrame, are implemented to use deferred execution. Deferred execution means that operations on Xorbits objects are not executed immediately as they are called. Instead, Xorbits builds an execution plan and the plan will not be executed until the result is actually required.

Currently, execution will be triggered in the following situations:

  1. repr is called.

  2. str is called.

  3. Output methods are called. For example, DataFrame.to_csv() is called.

  4. Critical information is missing. For example, the dtypes of a DataFrame.

Deferred execution can greatly improve performance when you manipulate large datasets. Optimizations can be applied to the chained operations before calling the backend. For example, identical parts of an execution plan can be eliminated and executed only once.

To trigger the execution manually, you can use run(). You pass an Xorbits object or a list of Xorbits objects as the argument.

>>> import xorbits.numpy as np
>>> a = np.arange(3)
>>> a
array([0, 1, 2])