New submission from sjohn <sebastianj...@gmx.net>: To flatten lists of lists, e.g. [[0], [1], [2], ...], I found the short and quite python-like one-liner "sum(listoflists, [])". This, however, has absolutely awful performance: while the equivalent way of iterating by hand and extending a flat list is longer and uglier, it performs fast and in linear time. The sum() variant takes unacceptably long. I do not know why this should behave worse-than-linear...
---------- components: Interpreter Core files: testsumflat.py messages: 86658 nosy: sjohn severity: normal status: open title: Perhaps exponential performance of sum(listoflists, []) type: performance versions: Python 2.4, Python 2.5 Added file: http://bugs.python.org/file13795/testsumflat.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5855> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com