You know the len(result) before you create it, so use make() and avoid the unnecessary reallocations from append().