Skip to content

Commit e2ea65f

Browse files
dmelnichukisapego
authored andcommitted
NBL-19 Optimized cyclic bytes concatenation with bytearray
This closes #189
1 parent a4e34a7 commit e2ea65f

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

pyignite/datatypes/complex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ def from_python(cls, value):
113113
length = 1
114114
header.length = length
115115
setattr(header, cls.type_or_id_name, type_or_id)
116-
buffer = bytes(header)
116+
buffer = bytearray(header)
117117

118118
for x in value:
119119
buffer += infer_from_python(x)
120-
return buffer
120+
return bytes(buffer)
121121

122122

123123
class WrappedDataObject(IgniteDataType):
@@ -294,12 +294,12 @@ def from_python(cls, value, type_id=None):
294294
)
295295
if hasattr(header, 'type'):
296296
header.type = type_id
297-
buffer = bytes(header)
297+
buffer = bytearray(header)
298298

299299
for k, v in value.items():
300300
buffer += infer_from_python(k)
301301
buffer += infer_from_python(v)
302-
return buffer
302+
return bytes(buffer)
303303

304304

305305
class MapObject(Map):

pyignite/datatypes/internal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ def from_python(self, value):
170170
header_class = self.build_header_class()
171171
header = header_class()
172172
header.length = length
173-
buffer = bytes(header)
173+
buffer = bytearray(header)
174174

175175
for i, v in enumerate(value):
176176
for default_key, default_value in self.defaults.items():
177177
v.setdefault(default_key, default_value)
178178
for name, el_class in self.following:
179179
buffer += el_class.from_python(v[name])
180180

181-
return buffer
181+
return bytes(buffer)
182182

183183

184184
@attr.s
@@ -472,8 +472,8 @@ def from_python(self, value):
472472
value = [value]
473473
length = 1
474474
header.length = length
475-
buffer = bytes(header)
475+
buffer = bytearray(header)
476476

477477
for x in value:
478478
buffer += infer_from_python(x)
479-
return buffer
479+
return bytes(buffer)

pyignite/datatypes/primitive_arrays.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ def from_python(cls, value):
9797
)
9898
length = len(value)
9999
header.length = length
100-
buffer = bytes(header)
100+
buffer = bytearray(header)
101101

102102
for x in value:
103103
buffer += cls.primitive_type.from_python(x)
104-
return buffer
104+
return bytes(buffer)
105105

106106

107107
class ByteArray(PrimitiveArray):

pyignite/datatypes/standard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,11 @@ def from_python(cls, value):
643643
)
644644
length = len(value)
645645
header.length = length
646-
buffer = bytes(header)
646+
buffer = bytearray(header)
647647

648648
for x in value:
649649
buffer += cls.standard_type.from_python(x)
650-
return buffer
650+
return bytes(buffer)
651651

652652

653653
class StringArray(StandardArray):
@@ -807,11 +807,11 @@ def from_python(cls, value):
807807
length = len(value)
808808
header.length = length
809809
header.type_id = type_id
810-
buffer = bytes(header)
810+
buffer = bytearray(header)
811811

812812
for x in value:
813813
buffer += cls.standard_type.from_python(x)
814-
return buffer
814+
return bytes(buffer)
815815

816816
@classmethod
817817
def to_python(cls, ctype_object, *args, **kwargs):

0 commit comments

Comments
 (0)