Assumedly the point of this is for performance, so that something like
(x + y + z) + w doesn't require rebuilding x + y + z.
I've thought for some time that Add should save its coeff: term
dictionary, to make further additions faster. I'm not sure if this
requires mutability.
I believe mutability can work for builder classes,
but it requires very careful bookkeeping, to invalidate anything pointing to it once it mutates.
And as you noted, it can't be included in the hash of any
mutable object. So in general, the mutable builder should be
considered a cached preprocessing step.
>>> a = Add(mutable=True)
>>> a.args
[]
>>> a.args.append(3)
>>> a.args.append(x)
3 + x
>>> a.args.extend([y, y])
>>> a
3 + x + y**2
>>> a.args
[3, x, y**2]
>>> a.as_immutable().args
(3, x, y**2)
Assumedly the point of this is for performance, so that something like
(x + y + z) + w doesn't require rebuilding x + y + z.
I've thought for some time that Add should save its coeff: term
dictionary, to make further additions faster. I'm not sure if this
requires mutability.
> email to sympy+unsubscribe@googlegroups.com.
> To post to this group, send email to sy...@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/ecc4eaa9-28dc-44a4-9ed0-402adea432e5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@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/CAKgW%3D6JiU_Qixnk3Eon8P_rBwxUNf5gs%2BiFEcWmM3%3DYC_eTYxg%40mail.gmail.com.
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@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/ecc4eaa9-28dc-44a4-9ed0-402adea432e5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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+un...@googlegroups.com.