Skip to content

Commit 682398f

Browse files
committed
avoiding attribute lookup for every single element in the array
1 parent 616ea27 commit 682398f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

wolframclient/language/array.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from wolframclient.exception import WolframLanguageException
44
from wolframclient.serializers.wxfencoder import constants
55
from wolframclient.utils.encoding import concatenate_bytes
6+
from wolframclient.utils.functional import map
67

78
try:
89
from collections.abc import Sequence
@@ -27,7 +28,7 @@ def _valid_type_or_fail(self, type):
2728
)
2829

2930
def tobytes(self):
30-
return concatenate_bytes(self.struct.pack(el) for el in self.array)
31+
return concatenate_bytes(map(self.struct.pack, self.array))
3132

3233
def __getitem__(self, k):
3334
return self.array[k]

0 commit comments

Comments
 (0)