On 10 July 2013 17:18, Ethan Furman <et...@stoneleaf.us> wrote: > On 07/10/2013 08:54 AM, Joshua Landau wrote: >> >> On 10 July 2013 10:00, Steven D'Aprano <st...@pearwood.info> wrote: >>> >>> On Wed, 10 Jul 2013 07:55:05 +0000, Mats Peterson wrote: >>> >>>> A moderator who calls himself “animuson” on Stack Overflow doesn’t want >>>> to face the truth. He has deleted all my postings regarding Python >>>> regular expression matching being extremely slow compared to Perl. >>> >>> >>> That's by design. We don't want to make the same mistake as Perl, where >>> every problem is solved by a regular expression: >>> >>> >>> http://neilk.net/blog/2000/06/01/abigails-regex-to-test-for-prime-numbers/ >>> >>> so we deliberately make regexes as slow as possible so that programmers >>> will look for a better way to solve their problem. If you check the >>> source code for the re engine, you'll find that for certain regexes, it >>> busy-waits for anything up to 30 seconds at a time, deliberately wasting >>> cycles. >> >> >> I hate to sound like this but do you realise that this is exactly what >> you're arguing for when saying that sum() shouldn't use "+="? > > > my_obj = SomeKoolClass() > my_obj.modify_in_some_kool_way() > new_result = sum([SKC1, SKC2, SKC3], my_obj) > > Guess what? You've just changed my_obj.
You're extrapolating too quickly. The first "+" is a copying "+", the rest add in-place to the new object. Thus, no unexpected side effect. -- http://mail.python.org/mailman/listinfo/python-list