]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
cdecimal docs, link to pypi
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 11 Dec 2010 22:53:02 +0000 (17:53 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 11 Dec 2010 22:53:02 +0000 (17:53 -0500)
lib/sqlalchemy/types.py

index 3e592ea51435f6e1cecf6590292c82e176f8b510..c66624b5f8907d45cb45e92ccbf7ce75d5e79033 100644 (file)
@@ -1013,6 +1013,38 @@ class Numeric(_DateAffinity, TypeEngine):
     ``decimal.Decimal`` objects by default, applying
     conversion as needed.
 
+    Note that the `cdecimal <http://pypi.python.org/pypi/cdecimal/>`_ library 
+    is a high performing alternative
+    to Python's built-in ``decimal.Decimal`` type, which performs very poorly
+    in high volume situations.   SQLAlchemy 0.7 is tested against ``cdecimal``
+    and supports it fully.  The type is not necessarily supported by 
+    DBAPI implementations however, most of which contain an import
+    for plain ``decimal`` in their source code, even though
+    some such as psycopg2 provide hooks for alternate adapters.   
+    SQLAlchemy imports ``decimal`` globally as well.  While the 
+    alternate ``Decimal`` class can be patched into SQLA's ``decimal`` module,
+    overall the most straightforward and foolproof way to use 
+    "cdecimal" given current DBAPI and Python support is to patch it directly 
+    into sys.modules before anything else is imported::
+    
+        import sys
+        import cdecimal
+        sys.modules["decimal"] = cdecimal
+    
+    While the global patch is a little ugly, it's particularly 
+    important to use just one decimal library at a time since 
+    Python Decimal and cdecimal Decimal objects 
+    are not currently compatible *with each other*::
+    
+        >>> import cdecimal
+        >>> import decimal
+        >>> decimal.Decimal("10") == cdecimal.Decimal("10")
+        False
+
+    SQLAlchemy will provide more natural support of 
+    cdecimal if and when it becomes a standard part of Python
+    installations and is supported by all DBAPIs.
+
     """
 
     __visit_name__ = 'numeric'
@@ -1048,37 +1080,6 @@ class Numeric(_DateAffinity, TypeEngine):
         which case ``asdecimal=False`` will at least remove the extra
         conversion overhead.
         
-        Note that the "cdecimal" library is a high performing alternative
-        to Python's built-in "decimal" type, which performs very poorly
-        in high volume situations.   SQLAlchemy 0.7 is tested against "cdecimal"
-        as well and supports it fully.  The type is not necessarily supported by 
-        DBAPI implementations however, most of which contain an import
-        for plain "decimal" in their source code, even though
-        some such as psycopg2 provide hooks for alternate adapters.   
-        SQLAlchemy imports "decimal" globally as well.  While the 
-        alternate "Decimal" class can be patched into SQLA's "decimal" module,
-        overall the most straightforward and foolproof way to use 
-        "cdecimal" given current support is to patch it directly 
-        into sys.modules before anything else is imported::
-        
-            import sys
-            import cdecimal
-            sys.modules["decimal"] = cdecimal
-        
-        While the global patch is a little ugly, it's particularly 
-        important to use just one decimal library at a time since 
-        Python Decimal and cdecimal Decimal objects 
-        are not currently compatible *with each other*::
-        
-            >>> import cdecimal
-            >>> import decimal
-            >>> decimal.Decimal("10") == cdecimal.Decimal("10")
-            False
-
-        SQLAlchemy will provide more automatic support of 
-        cdecimal if and when it becomes a standard part of Python
-        installations and is supported by all DBAPIs.
-        
         """
         self.precision = precision
         self.scale = scale