MCPcopy Create free account
hub / github.com/ccxt/ccxt / to_bytes

Method to_bytes

python/ccxt/static_dependencies/msgpack/ext.py:97–116  ·  view source on GitHub ↗

Pack this Timestamp object into bytes. Used for pure-Python msgpack packing. :returns data: Payload for EXT message with code -1 (timestamp type) :rtype: bytes

(self)

Source from the content-addressed store, hash-verified

95 return Timestamp(seconds, nanoseconds)
96
97 def to_bytes(self):
98 """Pack this Timestamp object into bytes.
99
100 Used for pure-Python msgpack packing.
101
102 :returns data: Payload for EXT message with code -1 (timestamp type)
103 :rtype: bytes
104 """
105 if (self.seconds >> 34) == 0: # seconds is non-negative and fits in 34 bits
106 data64 = self.nanoseconds << 34 | self.seconds
107 if data64 & 0xFFFFFFFF00000000 == 0:
108 # nanoseconds is zero and seconds < 2**32, so timestamp 32
109 data = struct.pack("!L", data64)
110 else:
111 # timestamp 64
112 data = struct.pack("!Q", data64)
113 else:
114 # timestamp 96
115 data = struct.pack("!Iq", self.nanoseconds, self.seconds)
116 return data
117
118 @staticmethod
119 def from_unix(unix_sec):

Callers 14

encode_uintFunction · 0.45
decode_shortstringFunction · 0.45
RawEncodedMethod · 0.45
RawDecodedMethod · 0.45
ToBytesMethod · 0.45
checkMethod · 0.45
_packMethod · 0.45
to_bytesFunction · 0.45
generate_k_rfc6979Function · 0.45
to_bytes_no_padFunction · 0.45
totpMethod · 0.45
number_to_leMethod · 0.45

Calls 1

packMethod · 0.80

Tested by

no test coverage detected