Hacker News new | ask | show | jobs
by eru 3625 days ago
I have tried. Two things get in the way quickly, and that's even just expressing thing, not even looking at performance yet:

  * Python standard library functions, especially the ones on dicts, mutate and don't return the new dictionary.
  * Python's syntax for creating functions is awkward: lambdas are cumbersome, and so are the operator package and eg functools.partial; there's no really convenient way to compose functions.
1 comments

Your first point is actually something I really like about Python's API design: in general, methods operating on collections either mutate the collection /or/ they return it. So it's clear at the point of use whether you're dealing with the same object or a new one.

This is something that bugs me about the fluent builder pattern in Java -- continuing to return `this` until suddenly you don't any more, and you can't re-use 'intermediate' values because they're actually all the same object.

Sure. I'd just like to have a nice set of operations to manipulate dicts that don't mutate and return the result, too.