diff options
| author | J. Nick Koston <nick@koston.org> | 2023-04-24 22:32:17 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-04-25 10:20:36 -0400 |
| commit | 188cb4226ac7b337446689ab3498b4397d0b7d2d (patch) | |
| tree | bdd19819afc3daf710db47f536c1e2f3d6d9e855 /lib/sqlalchemy/sql | |
| parent | 32a17e60ba63f0278a754e1ab7e9ebf9460e07c5 (diff) | |
| download | sqlalchemy-188cb4226ac7b337446689ab3498b4397d0b7d2d.tar.gz | |
disable "bytes" handler for all drivers other than psycopg2
Improved row processing performance for "binary" datatypes by making the
"bytes" handler conditional on a per driver basis. As a result, the
"bytes" result handler has been disabled for nearly all drivers other than
psycopg2, all of which in modern forms support returning Python "bytes"
directly. Pull request courtesy J. Nick Koston.
Fixes: #9680
Closes: #9681
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9681
Pull-request-sha: 4f2fd88bd9af54c54438a3b72a2f30384b0f8898
Change-Id: I394bdcbebaab272e63b13cc02f60813b7aa76839
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 4e7514e38..ce579cca2 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -934,6 +934,9 @@ class _Binary(TypeEngine[bytes]): # both sqlite3 and pg8000 seem to return it, # psycopg2 as of 2.5 returns 'memoryview' def result_processor(self, dialect, coltype): + if dialect.returns_native_bytes: + return None + def process(value): if value is not None: value = bytes(value) |
