Turn objects into unique integers
Take the "best" way to encode Python objects as numbers and back, and put it as convenience methods on ffi. For example,
with ffi.unique_integer(x) as i: ... y = ffi.get_object_from_integer(i)
The with statement is used to know exactly for how long the integer i is supposed to remain valid. Something like that anyway; the API may need adaptations to also support non-with-statement approaches.