Status: New Owner: ---- Labels: Type-Defect Priority-Medium New issue 1515 by indrek.mandre: caching does not distinct ints and longs http://code.google.com/p/sympy/issues/detail?id=1515
Sympy caches Integer-s. But this caching does not distinct ints and longs. But some code inside sympy seems to require ints. For example here number '3' has been promoted to long, somehow, and matrix code fails: from sympy import * x, y, t = symbols('xyt') P1 = Poly(sympify('a3*t**3+a2*t**2+a1*t+a0-x'),t) print type(sympify(3).p) print type(P1.degree) zeros(P1.degree) with output: <type 'long'> <type 'long'> Traceback (most recent call last): File "bug.py", line 7, in <module> zeros(P1.degree) File "/home/soft/sympy-0.6.5.beta2/sympy/matrices/matrices.py", line 1517, in zeros n, m = _dims_to_nm( dims ) File "/home/soft/sympy-0.6.5.beta2/sympy/matrices/matrices.py", line 38, in _dims_to_nm raise ValueError("Matrix dimensions should positive integers!") ValueError: Matrix dimensions should positive integers! This inconsistency is very bad. Either use only ints or only longs. This kind of thing is also hidden and one can easily experience strange behaviour when writing more serious applications on their own. Hidden promotion of types will cost time and space. A thumbed down example of the inconsistency: sympify(3L) sympify(4) print type(sympify(3).p) print type(sympify(4).p) with output: <type 'long'> <type 'int'> There may be 3 bugs here: a) the first sympify somehow turns 3 into long b) the matrix code does not accept long c) int/long inconsistency I guess a and b can be fixed trivially, but c is a fundamental issue. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-issues" group. To post to this group, send email to sympy-issues@googlegroups.com To unsubscribe from this group, send email to sympy-issues+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-issues?hl=en -~----------~----~----~----~------~----~------~--~---