projects
/
linpy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a4a564b
)
Define Symbol.__slots__ and Rational.__slots__
author
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 12:22:36 +0000
(14:22 +0200)
committer
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 12:35:41 +0000
(14:35 +0200)
linpy/linexprs.py
patch
|
blob
|
history
diff --git
a/linpy/linexprs.py
b/linpy/linexprs.py
index
d62c671
..
c100698
100644
(file)
--- 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.
"""
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.
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.
"""
fractions.Fraction classes.
"""
+ __slots__ = (
+ '_coefficients',
+ '_constant',
+ '_symbols',
+ '_dimension',
+ ) + Fraction.__slots__
+
def __new__(cls, numerator=0, denominator=None):
self = object().__new__(cls)
self._coefficients = {}
def __new__(cls, numerator=0, denominator=None):
self = object().__new__(cls)
self._coefficients = {}