py: Fix generator where state array was incorrectly indexed.

Generator objects now allocate the object and the state in one malloc.
This improvement fixes Issue #38.