Also, the conversion to dict was unnecessary, subs can take an iterator of tuples.
P_a = P.subs(zip(a, val_a)) -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/077286a5-eb72-4890-bf88-2c761a0145a4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.