Le 07/10/2011 03:19, Steven D'Aprano a écrit :
Given that strings are immutable, would it not be an obvious optimization for replace to return the source string unchanged if the old and new substrings are equal, and avoid making a potentially expensive copy?
I just implemented this optimization in 9c1b76936b79, but only if old and new substrings are the same object (old is new). *Compare* substrings (content) would slow down .replace() in most cases.
Victor _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com