Am 09.07.2017 um 23:19 schrieb Justin Pryzby:
Here's another revision; I haven't implemented named result iterators, and still couldn't get len() to work. Thanks for working
on this. This seems to go into the right direction.
Looks like it is not sufficient to just add a __len__() function in the C module, but you need to add a struct queryTypeSequenceMethods of type PySequenceMethods that contains the len() method, and point to this struct in the tp_as_sequence member of the queryType PyTypeObject.

See here:
https://docs.python.org/3/c-api/typeobj.html#c.PySequenceMethods

Besides sq_length, you should probably also implement sq_item. The other members of PySequenceMethods can be NULL.

One possibility is if col_types was stored in the queryObject struct,
and either invalidated by query() and populated lazily by first call
to result function or (probably) just populated by query() for use by
various result functions. Is that reasoanble?
Yes, it would make sense to cache the result of get_col_types(). You must not forget to free the memory in queryDealloc() then.

-- Chris
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to