Psycopg is written mostly in C and wraps the libpq library with the result of being both fast and secure.