Skip to content

Commit 89a8834

Browse files
charles-cooperfselmo
authored andcommitted
Use bytearray instead of itertools.repeat
from the docs: > Creating a zero-filled instance with a given length: bytearray(10) this has the highest likelihood of using a low-level implementation (hopefully, calloc) to allocate and zero the new array. - fix lint - remove dead import
1 parent 230b0ef commit 89a8834

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

eth/vm/memory.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import itertools
21
import logging
32

43
from eth._utils.numeric import (
@@ -32,7 +31,7 @@ def extend(self, start_position: int, size: int) -> None:
3231

3332
size_to_extend = new_size - len(self)
3433
try:
35-
self._bytes.extend(itertools.repeat(0, size_to_extend))
34+
self._bytes.extend(bytearray(size_to_extend))
3635
except BufferError:
3736
# we can't extend the buffer (which might involve relocating it) if a
3837
# memoryview (which stores a pointer into the buffer) has been created by

0 commit comments

Comments
 (0)