2012/9/11 Guido van Rossum <gu...@python.org>: > FWIW, I expect that there are few places where len(<constant string>) > is actually used.
I found one revelant example in the stdlib. if path.endswith('.dylib'): yield path[:-len('.dylib')] + suffix + '.dylib' else: yield path + suffix Cool, I'm not the only developer too lazy to copy/paste len('suffix') in a Python interpreter and then copy/paste the result in my code :-) "if text.endswith('suffix'): ... text[:-len('suffix')] ..." is a common pattern in my code. > However I expect it to be quite common for ord(), > where the same reasoning applies. Projects using the same code base for Python 2 and Python 3 contain a lot of inefficient code. For example, using the six library, a simple Unicode literal strings becomes a function code: u('unicode'). I expect that astoptimizer will be able to remove (or at least reduce!) the overhead of the six library and all checks on the Python version ("if PYTHON3: ... else: ..."). 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