<br><br>On Sunday, January 22, 2017, Wes Turner <<a href="mailto:wes.turner@gmail.com">wes.turner@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Have you looked at pyrsistent for immutable/functional/<wbr>persistent/copy-on-write data structures in Python?<div><div><br></div><div><a href="https://github.com/tobgu/pyrsistent/" target="_blank">https://github.com/tobgu/<wbr>pyrsistent/</a></div><div><br></div><div>(freeze() / thaw())</div><div><br></div><div>... e.g. List and Dict NamedTuple values are not immutable (because append() and update() still work)</div></div></blockquote><div><br></div><div>fn.py also has immutables:</div><div><a href="https://github.com/kachayev/fn.py/blob/master/README.rst#persistent-data-structures">https://github.com/kachayev/fn.py/blob/master/README.rst#persistent-data-structures</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br>On Sunday, January 22, 2017, Soni L. <<a href="javascript:_e(%7B%7D,'cvml','fakedme%2Bpy@gmail.com');" target="_blank">fakedme+py@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've been thinking of an Immutable Builder pattern and an operator to go with it. Since the builder would be immutable, this wouldn't work:<br>
<br>
long_name = mkbuilder()<br>
long_name.seta(a)<br>
long_name.setb(b)<br>
y = long_name.build()<br>
<br>
Instead, you'd need something more like this:<br>
<br>
long_name = mkbuilder()<br>
long_name = long_name.seta(a)<br>
long_name = long_name.setb(b)<br>
y = long_name.build()<br>
<br>
Or we could add an operator to simplify it:<br>
<br>
long_name = mkbuilder()<br>
long_name .= seta(a)<br>
long_name .= setb(b)<br>
y = long_name.build()<br>
<br>
(Yes, I'm aware you can x = mkbuilder().seta(a).setb(b), then y = x.build(). But that doesn't work if you wanna "fork" the builder. Some builders, like a builder for network connections of some sort, would work best if they were immutable/forkable.)<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a>Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</blockquote></div></div>
</blockquote>