From 882f615c68cd2d244a8d2cf480f3532a84bdb6fa Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 17 Jan 2014 17:36:43 -0500 Subject: - rework Oracle to no longer do its own unicode conversion; this has been observed to be very slow. this now has the effect of producing "conditional" unicode conversion for the Oracle backend, as it still returns NVARCHAR etc. as unicode [ticket:2911] - add new "conditional" functionality to unicode processors; the C-level function now uses PyUnicode_Check() as a fast alternative to the isinstance() check in Python --- lib/sqlalchemy/sql/sqltypes.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 702e77360..0cc90f26b 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -204,20 +204,11 @@ class String(Concatenable, TypeEngine): dialect.encoding, self.unicode_error) if needs_isinstance: - # we wouldn't be here unless convert_unicode='force' - # was specified, or the driver has erratic unicode-returning - # habits. since we will be getting back unicode - # in most cases, we check for it (decode will fail). - def process(value): - if isinstance(value, util.text_type): - return value - else: - return to_unicode(value) - return process + return processors.to_conditional_unicode_processor_factory( + dialect.encoding, self.unicode_error) else: - # here, we assume that the object is not unicode, - # avoiding expensive isinstance() check. - return to_unicode + return processors.to_unicode_processor_factory( + dialect.encoding, self.unicode_error) else: return None -- cgit v1.2.1