bruno

"mr storylets"

writer (derogatory). lead designer on Fallen London.

http://twitter.com/notbrunoagain


THESE POSTS ARE PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE POSTS OR THE USE OR OTHER DEALINGS IN THE POSTS.


Bluesky
brunodias.bsky.social

I'm looking through some old notes and I found this very correct set of observations:

Python is bad dot txt

Why is data science in the grip of this one madman’s fetishes?

  • The traditional collection-morphism functions (map, reduce, filter etc) return iterators and not the same class of collection you put in. They are therefore impostors meant as appendages to the list comprehension feature and not true implementations of those functions.
  • GvR apparently wanted to straight up remove these functions from Python 3, along with lambda? Which is fucking insane? ref: The fate of reduce() in Python 3000
  • join() is a method on the STRING YOU’RE JOINING WITH, not on the COLLECTION YOU’RE JOINING. You do ’,’.join(ary), which is again, insane.
  • bad names:
    • len() instead of length()

...I guess I didn't get around to writing down the other bad names but I'm sure there are many. I agree, Bruno from the past, Python is garbage.


You must log in to comment.

in reply to @bruno's post:

join() is a method on the STRING YOU’RE JOINING WITH, not on the COLLECTION YOU’RE JOINING. You do ’,’.join(ary), which is again, insane.

I remember looking this one up, it's an awkward thing that dates to before a bunch of the core types were objects and therefore had methods. They put it in the wrong place because it was the only place it could go, and then it never got fixed even though that was like pre-Python 1

I really don't like python, but 1) is good. The point of those functions is that they can be fused together so that a chain of map / filter can be executed in one pass rather than allocating and traversing an entire new list for every single operation.
The only reason Haskell can get away with its functions is that lists are (by virtue of being lazy) pretty much just iterators and that other data structures like vectors can be fused together through rewrite rules.

Also, 3) is ugly but makes sense since you can't define a method on string lists specifically :/

so that a chain of map / filter can be executed in one pass rather than allocating and traversing an entire new list for every single operation

it is the compiler's job to think about this. a language shouldn't have a standard function work with arbitrarily nonstandard semantics for the sake of optimization

But this isn't just an optimization, it also changes the semantics. Fusing the traversals together interleaves their side effects, so the compiler cannot just optimize intermediate lists away.

Python's implementation isn't unreasonable, its functions just don't work on lists, but on iterators, which are inherently explicitly fused collection traversals. They're more similar to foldl than lists tbh.
Having a way to guarantee fusion rather than relying on fragile optimizations is good IMO.

And I really wouldn't call this nonstandard, given that most major languages work exactly this way (e.g. Java, C#, Rust)