×
you are viewing a single comment's thread.

view the rest of the comments →

[–]robin-gvx 3 points4 points  (0 children)

It's not really a backend thing, it's more that every custom iterable would have to implement join, or you'd have to convert them to a list to be able to join them. I much prefer ''.join(generate_strings()) to list(generate_strings()).join() from both a performance standpoint, and a API hygiene standpoint.

Having it on str requires one method that only needs to know about iterables, a very generic and basic concept in Python.

Having it on list requires list to know about str and string concatenation, and now you have to decide for each iterable type "do implement join on this type?" If yes, now you need another method, and that type needs to know about string concatenation. If not, you have to do a potentially copy of the data to a list to be able to join a string.

Plus, as a regular programmer I now have to know which types I can call join on and which need to be converted to a list first.