File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def dimensions(self) -> int:
4141
4242 def to_list (self ) -> list [float ]:
4343 dim = len (self ._value )
44- return list (struct .unpack (f'{ dim } e' , self ._value . tobytes () ))
44+ return list (struct .unpack (f'{ dim } e' , self ._value ))
4545
4646 def to_numpy (self ) -> np .ndarray [tuple [int ], np .dtype [np .float16 ]]:
4747 return np .frombuffer (self ._value , dtype = np .float16 )
@@ -55,7 +55,7 @@ def to_binary(self) -> bytes:
5555 else :
5656 value = array .array ('H' , self ._value )
5757 value .byteswap ()
58- return struct .pack (f'>HH' , len (value ), 0 ) + value . tobytes ( )
58+ return struct .pack (f'>HH' , len (value ), 0 ) + memoryview ( value )
5959
6060 @classmethod
6161 def from_text (cls , value : str ) -> HalfVector :
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ def to_binary(self) -> bytes:
5353 else :
5454 value = array .array ('f' , self ._value )
5555 value .byteswap ()
56- return struct .pack (f'>HH' , len (value ), 0 ) + value . tobytes ( )
56+ return struct .pack (f'>HH' , len (value ), 0 ) + memoryview ( value )
5757
5858 @classmethod
5959 def from_text (cls , value : str ) -> Vector :
You can’t perform that action at this time.
0 commit comments