# New user \`update()\` function feature

**URL:** <https://discourse.processing.org/t/new-user-update-function-feature/43770>\
**Category:** py5\
**Created:** [January 27, 2024, 6:27am UTC](https://discourse.processing.org/t/new-user-update-function-feature/43770 "2024-01-27T06:27:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [January 27, 2024, 6:27am UTC](https://discourse.processing.org/t/new-user-update-function-feature/43770/1 "2024-01-27T06:27:33Z")

</div>

The next version of py5 will support a user `update()` function. This function will be called before each call to `draw()`.

The purpose of this new `update()` function is to provide an opportunity to execute Python code in the small gap of time between one call to `draw()` and the next. Normally this isn’t a large amount of time, perhaps 10-15% of the total execution time, but for py5, that’s time when the Python interpreter would otherwise be is idle. The `update()` function provides an opportunity to execute Python code during that time, and in a lot of cases can yield a 5-10% increase in the Sketch’s frame rate.

You can read more about it here:

> **[New user \`update()\` function · py5coding/py5generator · Discussion #408](https://github.com/py5coding/py5generator/discussions/408)**
>
> This discussion thread is to introduce a new py5 feature: a user update() function that is called before every call to draw(). I'll explain how it works and why it is useful. I'd like to hear other...

Happy to hear your thoughts and feedback!
