Skip to content

Commit ec7a054

Browse files
committed
Faster defaultlist
1 parent 6bc62c4 commit ec7a054

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ additional functionality.
4444
CI tests run on:
4545

4646
* Python 3.6+
47-
* Pypy
4847

4948
Examples are provided below, and the API documentation can always be found at
5049
readthedocs.org_.

reusables/default_list.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ def __init__(self, *args, factory=lambda: None, **kwargs):
1111

1212
def __getitem__(self, index):
1313
if index >= len(self):
14-
for i in range(index - len(self) + 1):
15-
self.append(self.factory())
14+
self.extend(self.factory() for _ in range(index - len(self) + 1))
1615
return super().__getitem__(index)

0 commit comments

Comments
 (0)