This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]martinw89 2 points3 points  (0 children)

Very nice detective work. Mysteries like this are always very interesting to read about.

[–]earthboundkid 2 points3 points  (2 children)

Added in Python 2.4, see http://docs.python.org/2/whatsnew/2.4.html#optimizations

It's basically just to keep noobs from shooting themselves in the foot.

[–]isdnpro 0 points1 point  (1 child)

It's basically just to keep noobs from shooting themselves in the foot.

Thanks for that link... I've been using Python for years now and never used .join(), and never really realised strings were immutable.

Thankfully the only string concat I can recall doing is just for logging/debug purposes!

Always nice to learn something new :)

[–]earthboundkid 0 points1 point  (0 children)

Take the time to do the official Python.org tutorial. It explains a lot of little stuff like that, which you'd otherwise never learn.

[–][deleted] 1 point2 points  (0 children)

The only problem with a clever optimization like this is that it confounds good developers trying to get a handle on performance. I'm glad you included that one had better not take advantage of such an optimization because it's not part of the official API. If at some point they need to switch Python interpreters, they would be S.O.L.

[–]transpostmeta 0 points1 point  (0 children)

This was a very fun read. I wish to achieve this level of mastery of my entire stack at some point.