]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
large speed improvement of the Interval type on non-native dialects
authorGaëtan de Menten <gdementen@gmail.com>
Thu, 29 Oct 2009 21:24:33 +0000 (21:24 +0000)
committerGaëtan de Menten <gdementen@gmail.com>
Thu, 29 Oct 2009 21:24:33 +0000 (21:24 +0000)
lib/sqlalchemy/types.py

index 63a339baf8501d1bfcc8b88b474524491f8850e3..92ff274f8848f5c5f7b06219924c67ed03a7dfcf 100644 (file)
@@ -1072,16 +1072,17 @@ class Interval(TypeDecorator):
     """
 
     impl = DateTime
+    epoch = dt.datetime.utcfromtimestamp(0)
 
     def process_bind_param(self, value, dialect):
         if value is None:
             return None
-        return dt.datetime.utcfromtimestamp(0) + value
+        return self.epoch + value
 
     def process_result_value(self, value, dialect):
         if value is None:
             return None
-        return value - dt.datetime.utcfromtimestamp(0)
+        return value - self.epoch
 
 class FLOAT(Float):
     """The SQL FLOAT type."""