I have a problem lambdifing a function that expects a large array. A simplified code replicating the same problem is:
from sympy import *
def fun(x):
f = []
for i,x_i in enumerate(x):
f.append(x_i**i)
return Matrix(f)
N = 256
x = Matrix([symbols("x_%s"%i) for i in range(N)])
fun_lam = lambdify((x,),fun(x))
which gives the following error:
Traceback (most recent call last):
File "bin/problem-lambdify.py", line 13, in <module>
fun_lam = lambdify((x,),fun(x))
File ".../env/lib/python3.4/site-packages/sympy-1.1rc1-py3.4.egg/sympy/utilities/lambdify.py", line 434, in lambdify
func = eval(lstr, namespace)
File "<string>", line 1
SyntaxError: more than 255 arguments
I suppose sympy at some point flattens the arguments and therefore causes this problem.
I can't think of a good way around it.
Apparently Python 3.7 (which will be released in 2018), will be removing this limitation. I know this doesn't help you right now (unless you want to run on a dev build of Python), but at least there's hope for the future.