News for hackers. Stuff that matters.
Re:Differences from Psycopg2 by andrewstuart on Tuesday October 10, 2023 @02:47PM (#37835904)
Interestingly, the native Python Postgres driver “Asyncpg” is faster than psycopg which is writhe in C.
Re:Differences from Psycopg2 by FreakLegion on Tuesday October 10, 2023 @03:52PM (#37836630)
Asyncpg isn't pure Python, if that's what you mean by native. It's a heavy user of Python's C API, which is why PyPy can't run it. But yes, Asyncpg does tend to be quite a bit faster than Psycopg2 in most cases.
Re:Differences from Psycopg2 by andrewstuart on Tuesday October 10, 2023 @04:13PM (#37836867)
OK I was wrong and stand corrected, asyncpg is not pure Python.

asyncpg has these two C files and also uses Cython as far as I can see.

https://github.com/MagicStack/asyncpg/blob/master/asyncpg/pr...

https://github.com/MagicStack/asyncpg/blob/master/asyncpg/pr...

If you are interested here is a post by the psycopg author about psycopg2 and 3 and performance versus asyncpg.

https://www.varrazzo.com/blog/2020/05/19/a-trip-into-optimis...

Re:Differences from Psycopg2 by mjoin on Tuesday October 10, 2023 @06:26PM (#37838523)
what do you mean by 'native'? or, in other words, what makes psycopg non-native?
Re:Differences from Psycopg2 by Chiron1991 on Wednesday October 11, 2023 @04:35AM (#37842206)
That's because psycopg adheres to the DBAPI standard (think of JDBC of the Python world). asyncpg deliberately ignores this standard for huge performance boosts.