def append(self, code, data):
        self._validate_code_size(code)
        self._initialize_in_memory_store()

        with self.env.begin(write=True) as txn:
            _id = self._new_id()
            try:
                code = code.encode()
            except AttributeError:
                pass
            try:
                data = data.encode()
            except AttributeError:
                pass
            txn.put(_id, code + data, db=self.index)
            self._add_code(_id, code)