[pypy-dev] PyPQ: a dbapi 2 PostgreSQL driver working with pypy

Igor Katson igor.katson at gmail.com
Tue Oct 4 16:51:58 CEST 2011

Hi, Dan,
before answering I'll describe the situation a bit.

there was a question today, if I know about pg8000 or psycopg2ct.

As for pg8000, pure python should be slower than ctypes, anyway, so I 
don't think these two should be compared.

But at the time of making pypq, I did not know about psycopg2ct. A 
couple of weeks ago there was no mention of it on the pypy psycopg2 
compatibility page, and yesterday (when I decided to make pypq) I did 
not find it while googling the topic. Though if I did know that, I 
wouldn't write my own implementation.

Luckily, it took me only one day of coding, and therefore there are two 
key differences:
- pypq is a lot simpler. You can look at the code of both to see that
- pypq does not try to be psycopg2, only a couple of functions from 
there for django compatibility

As soon as there is another project of this kind, I'm not sure if I'll 
go on with this. For production usage, pypq needs at least a complete 
test coverage, so DO NOT USE it in production, it is very alpha.

About your questions, Dan:

- this is not a replacement for psycopg2, as psycopg2ct is, but instead 
a dbapi2-compliant driver, which looks almost the same as psycopg2, 
cause they share the API. Making it a replacement was not a concern

- i did not profile the code, just tested the results on my sites 
visually, and on cpython 2.7, I got roughly the same speeds as with 
psycopg2. It should be pretty fast, but if there is a bottleneck, the 
code is pretty simple to explore and fix. What I can think of now is 
processing very large result sets might be slow, cause for every cell 
there is a type cast going on, especially for complex types like 
datetime.timedelta. See datatypes.py for details.

But still, the fact, that a working postgres driver for python could be 
written in a day, is awesome :) So as long as the code is simple, it 
could be an alternative.


On 10/04/2011 05:45 PM, Dan Loewenherz wrote:
> Hi Igor,
> This is awesome.
> Quick questions: What is the feature parity with psycopg2? Are there 
> any large components that aren't up to speed and need working on?
> Thanks!
> Dan
> mobile 786-201-1161 | web http://dlo.me/ | twitter @dwlz 
> <http://twitter.com/dwlz>
> On Tue, Oct 4, 2011 at 3:07 AM, Igor Katson <igor.katson at gmail.com 
> <mailto:igor.katson at gmail.com>> wrote:
>     Hi, pypy developers.
>     check out pypq, a dbapi 2 PostgreSQL driver working with pypy
>     http://pypi.python.org/pypi/pypq
>     I've made it to test how will my existing django sites work with pypy
>     I will be glad for any help.
>     Feel free to contact me if you want to participate.
>     _______________________________________________
>     pypy-dev mailing list
>     pypy-dev at python.org <mailto:pypy-dev at python.org>
>     http://mail.python.org/mailman/listinfo/pypy-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20111004/f11bcfd6/attachment.html>

More information about the pypy-dev mailing list