Create Module from a LLVM *bitcode* (a bytes object).
553381
def parse_bitcode(bitcode, context=None):
    
    if context is None:
        context = get_global_context()
    buf = c_char_p(bitcode)
    bufsize = len(bitcode)
    with ffi.OutputString() as errmsg:
        mod = ModuleRef(ffi.lib.LLVMPY_ParseBitcode(
            context, buf, bufsize, errmsg), context)
        if errmsg:
            mod.close()
            raise RuntimeError(
                "LLVM bitcode parsing error\n{0}".format(errmsg))
    return mod
500353
def _from_bytes(bytes, byteorder="big", signed=False):
    """"""
    return int.from_bytes(bytes, byteorder=byteorder, signed=signed)
581026
def from_bytes(cls, bitstream, prefix_len=None):
        '''
        
        '''
        # Convert to ConstBitStream (if not already provided)
        if not isinstance(bitstream, ConstBitStream):
            if isinstance(bitstream, Bits):
                bitstream = ConstBitStream(auto=bitstream)
            else:
                bitstream = ConstBitStream(bytes=bitstream)

        # Skip the reserved bits
        rsvd1 = bitstream.read(8)

        # Read the flags (and ignore them, no flags are defined yet)
        flags = bitstream.readlist('8*bool')

        # Read the type
        type_nr = bitstream.read('uint:8')

        # Skip the reserved bits
        rsvd2 = bitstream.read(8)

        # Read the length
        length = bitstream.read('uint:16')

        # Read the data
        data = bitstream.read(length * 8)

        # Look for the right class
        from pylisp.utils.lcaf import type_registry
        type_class = type_registry.get_type_class(type_nr)
        if not type_class:
            raise ValueError("Can't handle LCAF type {0}".format(type_nr))

        # Let the specific class handle it from now on
        return type_class._from_data_bytes(data, prefix_len,
                                           rsvd1, flags, rsvd2)
1306002
def new_from_memory(cls, data):
        """"""

        size = len(data)
        copy = g_memdup(data, size)
        ptr = cast(copy, POINTER(guint8))
        try:
            with gerror(GIError) as error:
                return GITypelib._new_from_memory(ptr, size, error)
        except GIError:
            free(copy)
            raise
442961
def create_from_ll(cls, lls:LabelLists, bs:int=64, val_bs:int=None, ds_tfms:Optional[TfmList]=None,
                num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callable]]=None, device:torch.device=None,
                test:Optional[PathOrStr]=None, collate_fn:Callable=data_collate, size:int=None, no_check:bool=False,
                resize_method:ResizeMethod=None, mult:int=None, padding_mode:str='reflection',
                mode:str='bilinear', tfm_y:bool=False)->'ImageDataBunch':
        ""
        lls = lls.transform(tfms=ds_tfms, size=size, resize_method=resize_method, mult=mult, padding_mode=padding_mode,
                            mode=mode, tfm_y=tfm_y)
        if test is not None: lls.add_test_folder(test)
        return lls.databunch(bs=bs, val_bs=val_bs, dl_tfms=dl_tfms, num_workers=num_workers, collate_fn=collate_fn,
                             device=device, no_check=no_check)
844755
def create_module_file(txt, directory):
    """"""
    name = nonpresent_module_filename()
    path = os.path.join(directory, name)
    with open(path, 'w') as fh:
        fh.write(txt)
    return path
707540
def from_int(value):
        """"""
        if not isinstance(value, int):
            raise PyVLXException("value_has_to_be_int")
        if not Parameter.is_valid_int(value):
            raise PyVLXException("value_out_of_range")
        return bytes([value >> 8 & 255, value & 255])
253060
def to_bytes(s, encoding="utf8"):
    """"""
    if PY_VERSION == 2:
        b = bytes(s)
    elif PY_VERSION == 3:
        b = bytes(s, encoding)
    else:
        raise ValueError("Is Python 4 out already?")

    return b
1145241
def BitField(value, length, signed=False, min_value=None, max_value=None, encoder=ENC_INT_DEFAULT, fuzzable=True, name=None, full_range=False):
    '''
    
    '''
    if not full_range:
        return _LibraryBitField(value, length, signed, min_value, max_value, encoder, fuzzable, name)
    return _FullRangeBitField(value, length, signed, min_value, max_value, encoder, fuzzable, name)
418478
def from_byte_array(cls, bytes_):
        
        runs = cls._length_run_coding.parse(bytes_)
        pixels = (run.pixels for run in runs.data)
        data = "".join(itertools.chain.from_iterable(pixels))
        return cls(data)
1329661
def dump_memdb(self, with_source_contents=True, with_names=True):
        """"""
        len_out = _ffi.new('unsigned int *')
        buf = rustcall(
            _lib.lsm_view_dump_memdb,
            self._get_ptr(), len_out,
            with_source_contents, with_names)
        try:
            rv = _ffi.unpack(buf, len_out[0])
        finally:
            _lib.lsm_buffer_free(buf)
        return rv
418033
def from_blob(cls, blob):
        
        stream = BytesIO(blob)
        return cls._from_stream(stream, blob)
982757
def write_bytecode(self, f):
        """"""
        if self.code is None:
            raise TypeError('can\'t write empty bucket')
        f.write(bc_magic)
        pickle.dump(self.checksum, f, 2)
        marshal_dump(self.code, f)
508302
def from_bytes(cls, bitstream):
        '''
        
        '''
        from pylisp.packet.lisp.control import type_registry

        # Convert to ConstBitStream (if not already provided)
        if not isinstance(bitstream, ConstBitStream):
            if isinstance(bitstream, Bits):
                bitstream = ConstBitStream(auto=bitstream)
            else:
                bitstream = ConstBitStream(bytes=bitstream)

        # Peek at the bitstream to see which type it is
        type_nr = bitstream.peek('uint:4')

        # Look for the right class
        type_class = type_registry.get_type_class(type_nr)
        if not type_class:
            raise ValueError("Can't handle message type {0}".format(type_nr))

        # Let the specific class handle it from now on
        return type_class.from_bytes(bitstream)
1075334
public final static Function<BigInteger, BigInteger> module(short module) {
        return new Module(fromNumber(Short.valueOf(module)));
    }
696162
def from_bytes(rawbytes):
        '''
        
        '''
        ipopts = IPOptionList()

        i = 0
        while i < len(rawbytes):
            opttype = rawbytes[i]
            optcopied = opttype >> 7         # high order 1 bit
            optclass = (opttype >> 5) & 0x03 # next 2 bits
            optnum = opttype & 0x1f          # low-order 5 bits are optnum
            optnum = IPOptionNumber(optnum)
            obj = IPOptionClasses[optnum]()
            eaten = obj.from_bytes(rawbytes[i:])
            i += eaten
            ipopts.append(obj)
        return ipopts
887720
def build_module(name, doc=None):
    """"""
    node = nodes.Module(name, doc, pure_python=False)
    node.package = False
    node.parent = None
    return node