Performance

Custom Scripts

By default, custom scripts send the content of the entire workbook to the backend. Most of the time, this is not required, so you can include or exclude specific sheets via the include and exclude config, see your specific integration for more details: Office.js Add-ins, VBA, Google Apps Script, or Office Scripts.

Custom Functions

While xlwings can handle 10,000s of custom functions, there is an easy way to to make custom functions perform better: reduce their number. And this can often be achieved by using dynamic arrays in place of many single-cell functions. Consider the following example:

import numpy as np
from xlwings.server import func, arg


@func
def mysum(x, y, z):
    return x + y + z


@func
@arg("x", np.array, ndim=2)
@arg("y", np.array)
def myarraysum(x, y, z):
    return x + y + z

The first example results in 100 individual function calls on the screenshot:

../_images/performance_individual_function.png

The second example results in just a single function call:

../_images/performance_array_function.png