Dump data structure to str.

    Here float_bits is either 32 or 64.
356343
def dumps(x, float_bits=DEFAULT_FLOAT_BITS):
    
    with lock:
        if float_bits == 32:
            encode_func[float] = encode_float32
        elif float_bits == 64:
            encode_func[float] = encode_float64
        else:
            raise ValueError('Float bits (%d) is not 32 or 64' % float_bits)
        r = []
        encode_func[type(x)](x, r)
    return b''.join(r)
1326252
def read_plain_float(file_obj, count):
    """"""
    return struct.unpack("<{}f".format(count).encode("utf-8"), file_obj.read(4 * count))
222230
def hex16_to_u64be(data):
    """"""
    return int(data[14:16] + data[12:14] + data[10:12] + data[8:10] + data[6:8] + data[4:6] + data[2:4] + data[0:2], 16)
1369394
def dumps(asts):
    
    d = asts.values.tostring()
    t = asts.index.values.astype(float).tostring()
    lt = struct.pack('<L', len(t))
    i = asts.name.encode('utf-8')
    li = struct.pack('<L', len(i))
    try:  # python 2
        return buffer(zlib.compress(li + lt + i + t + d))
    except NameError:  # python 3
        return zlib.compress(li + lt + i + t + d)
33681
def _choose_float_dtype(dtype, has_offset):
    """"""
    # Keep float32 as-is.  Upcast half-precision to single-precision,
    # because float16 is "intended for storage but not computation"
    if dtype.itemsize <= 4 and np.issubdtype(dtype, np.floating):
        return np.float32
    # float32 can exactly represent all integers up to 24 bits
    if dtype.itemsize <= 2 and np.issubdtype(dtype, np.integer):
        # A scale factor is entirely safe (vanishing into the mantissa),
        # but a large integer offset could lead to loss of precision.
        # Sensitivity analysis can be tricky, so we just use a float64
        # if there's any offset at all - better unoptimised than wrong!
        if not has_offset:
            return np.float32
    # For all other types and circumstances, we just use float64.
    # (safe because eg. complex numbers are not supported in NetCDF)
    return np.float64
840010
def uint64(self, val):
        """"""
        try:
            self.msg += [pack("!Q", val)]
        except struct.error:
            raise ValueError("Expected uint64")
        return self
18176
def _dump_multilinestring(obj, big_endian, meta):
    
    coords = obj['coordinates']
    vertex = coords[0][0]
    num_dims = len(vertex)

    wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder(
        'MultiLineString', num_dims, big_endian, meta
    )

    ls_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['LineString']
    if big_endian:
        ls_type = BIG_ENDIAN + ls_type
    else:
        ls_type = LITTLE_ENDIAN + ls_type[::-1]

    # append the number of linestrings
    wkb_string += struct.pack('%sl' % byte_order, len(coords))

    for linestring in coords:
        wkb_string += ls_type
        # append the number of vertices in each linestring
        wkb_string += struct.pack('%sl' % byte_order, len(linestring))
        for vertex in linestring:
            wkb_string += struct.pack(byte_fmt, *vertex)

    return wkb_string
247824
def unpack_bitstring(length, is_float, is_signed, bits):
    # type: (int, bool, bool, typing.Any) -> typing.Union[float, int]
    

    if is_float:
        types = {
            32: '>f',
            64: '>d'
        }

        float_type = types[length]
        value, = struct.unpack(float_type, bytearray(int(''.join(b), 2)  for b in grouper(bits, 8)))
    else:
        value = int(bits, 2)

        if is_signed and bits[0] == '1':
            value -= (1 << len(bits))

    return value
669042
def to_binary(decimal, length):
        
        b = bitstring.Bits(int=decimal, length=length)
        return b.bin
658086
def dumps(number):
    
    if not isinstance(number, integer_types):
        raise TypeError('number must be an integer')

    if number < 0:
        return '-' + dumps(-number)

    value = ''

    while number != 0:
        number, index = divmod(number, len(alphabet))
        value = alphabet[index] + value

    return value or '0'
417439
def _encode(self, value):
        ""
        if isinstance(value, bytes):
            return value
        elif isinstance(value, (int, long)):
            value = str(value).encode('utf-8')
        elif isinstance(value, float):
            value = repr(value).encode('utf-8')
        elif not isinstance(value, basestring):
            value = str(value).encode('utf-8')
        else:
            value = value.encode('utf-8', 'strict')
        return value
847691
def convert_registers_to_float(registers):
      
    b = bytearray(4)
    b [0] = registers[0] & 0xff
    b [1] = (registers[0] & 0xff00)>>8 
    b [2] = (registers[1] & 0xff)
    b [3] = (registers[1] & 0xff00)>>8
    returnValue = struct.unpack('<f', b)            #little Endian
    return returnValue
1258042
def serialize(self, value):
        
        if isinstance(value, float) and self.as_type is six.text_type:
            value = u'{0:.{1}f}'.format(value, self.float_places)
            value = self.as_type(value)
        elif self.as_type is six.text_type:
            if isinstance(value, bool):
                # Store bools as 1/0 instead of True/False.
                value = six.text_type(int(bool(value)))
            elif isinstance(value, bytes):
                value = value.decode('utf-8', 'ignore')
            else:
                value = six.text_type(value)
        else:
            value = self.as_type(value)

        if self.suffix:
            value += self.suffix

        return value
827201
def __BitList_to_String(self, data):
		""""""
		result = []
		pos = 0
		c = 0
		while pos < len(data):
			c += data[pos] << (7 - (pos % 8))
			if (pos % 8) == 7:
				result.append(c)
				c = 0
			pos += 1

		if _pythonMajorVersion < 3:
			return ''.join([ chr(c) for c in result ])
		else:
			return bytes(result)
394577
def read_plain_int64(file_obj, count):
    """"""
    return struct.unpack("<{}q".format(count).encode("utf-8"), file_obj.read(8 * count))
245273
def binary_dumps(obj, alt_format=False):
    
    return b''.join(_binary_dump_gen(obj, alt_format=alt_format))
517779
def toFloat(val):
    """"""
    hex = "0123456789abcdef"
    return float(hex.find(val[0]) * 16 + hex.find(val[1]))