It would be great if you could tell us a bit more about this 'cobj' object: the name does not tell me really what it is, nor what is it's type. Maybe a different name would help readability, and a bit more docstrings also.