Processing.py issue with user-created generator (yield)

New to Processing but experienced in programming, especially python. I decided implementing Conway’s Game of Life would be a good project to get a feel for how to use Processing.py

My code involved a function that returned a generator for the neighbors of a given cell, yielding the coordinates for each neighboring cell as a tuple. This is quite common in python, and as far as I know has no performance issues in native python as compared with compiling a list of the neighbors and returning it.

Upon running the sketch, however, I was experiencing periodic pauses in the animation loop. I spent quite a bit of time trying to find the performance hiccup, and eventually tried changing the generator code to just construct and return a list. To my surprise, this immediately fixed the issue.

Is there something inherently inefficient about using generator functions in Processing.py (i.e. functions that yield instead of return)? Has anyone else run into a similar issue? I’m fine avoiding using yield but I would like to understand why it causes a problem.

1 Like

Ignore me; I don’t know what I am taking about.

Hi!

Processing Python Mode is based on Jython, a Python 2.7 interpreter that uses the JVM.
I really don’t know why the user-created generator has such a performance penalty :frowning:

If you can think of a minimal example to test this issue it might be nice to open an issue at https://github.com/jdf/Processing.py-Bugs/

For your amusement, yet another Conway’s Game of Life naive implementation:

1 Like

Thanks for the reply, I will try to find a minimal example and open an issue.

1 Like