From: Vivien Maisonneuve <v.maisonneuve@gmail.com>
Date: Tue, 19 Aug 2014 12:22:36 +0000 (+0200)
Subject: Define Symbol.__slots__ and Rational.__slots__
X-Git-Tag: 1.0~51
X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/commitdiff_plain/538cd0d05962f48885e8dd68c93a0a1af67b9607?hp=a4a564b4061ca0a495f2f2dba784d28b685b6f1d

Define Symbol.__slots__ and Rational.__slots__
---

diff --git a/linpy/linexprs.py b/linpy/linexprs.py
index d62c671..c100698 100644
--- a/linpy/linexprs.py
+++ b/linpy/linexprs.py
@@ -450,6 +450,13 @@ class Symbol(LinExpr):
     Two instances of Symbol are equal if they have the same name.
     """
 
+    __slots__ = (
+        '_name',
+        '_constant',
+        '_symbols',
+        '_dimension',
+    )
+
     def __new__(cls, name):
         """
         Return a symbol with the name string given in argument.
@@ -582,6 +589,13 @@ class Rational(LinExpr, Fraction):
     fractions.Fraction classes.
     """
 
+    __slots__ = (
+        '_coefficients',
+        '_constant',
+        '_symbols',
+        '_dimension',
+    ) + Fraction.__slots__
+
     def __new__(cls, numerator=0, denominator=None):
         self = object().__new__(cls)
         self._coefficients = {}