Example #1
0
 def setitem_str(self, w_key, w_value, shadows_type=True):
     key = self.space.str_w(w_key)
     i = BUILTIN_TO_INDEX.get(key, -1)
     if i != -1:
         self.shadowed[i] = w_value
     self.content[key] = w_value
     return self
Example #2
0
 def setitem_str(self, w_key, w_value, shadows_type=True):
     key = self.space.str_w(w_key)
     i = BUILTIN_TO_INDEX.get(key, -1)
     if i != -1:
         self.shadowed[i] = w_value
     self.content[key] = w_value
     return self
Example #3
0
 def impl_delitem(self, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     if space.is_w(w_key_type, space.w_str):
         key = space.str_w(w_key)
         del self.content[key]
         i = BUILTIN_TO_INDEX.get(key, -1)
         if i != -1:
             self.shadowed[i] = None
     elif _is_sane_hash(space, w_key_type):
         raise KeyError
     else:
         self._as_rdict().delitem(w_key)
Example #4
0
 def _optimize_builtin_call(self, call):
     if not self.space.config.objspace.opcodes.CALL_LIKELY_BUILTIN or \
             not self._call_has_simple_args(call) or \
             not isinstance(call.func, ast.Name):
         return False
     func_name = call.func
     assert isinstance(func_name, ast.Name)
     name_scope = self.scope.lookup(func_name.id)
     if name_scope == symtable.SCOPE_GLOBAL_IMPLICIT or \
             name_scope == symtable.SCOPE_UNKNOWN:
         builtin_index = BUILTIN_TO_INDEX.get(func_name.id, -1)
         if builtin_index != -1:
             if call.args:
                 args_count = len(call.args)
                 self.visit_sequence(call.args)
             else:
                 args_count = 0
             arg = builtin_index << 8 | args_count
             self.emit_op_arg(ops.CALL_LIKELY_BUILTIN, arg)
             return True
     return False
Example #5
0
 def _optimize_builtin_call(self, call):
     if not self.space.config.objspace.opcodes.CALL_LIKELY_BUILTIN or \
             not self._call_has_simple_args(call) or \
             not isinstance(call.func, ast.Name):
         return False
     func_name = call.func
     assert isinstance(func_name, ast.Name)
     name_scope = self.scope.lookup(func_name.id)
     if name_scope == symtable.SCOPE_GLOBAL_IMPLICIT or \
             name_scope == symtable.SCOPE_UNKNOWN:
         builtin_index = BUILTIN_TO_INDEX.get(func_name.id, -1)
         if builtin_index != -1:
             if call.args:
                 args_count = len(call.args)
                 self.visit_sequence(call.args)
             else:
                 args_count = 0
             arg = builtin_index << 8 | args_count
             self.emit_op_arg(ops.CALL_LIKELY_BUILTIN, arg)
             return True
     return False
Example #6
0
 def impl_setitem_str(self, key, w_value, shadows_type=True):
     i = BUILTIN_TO_INDEX.get(key, -1)
     if i != -1:
         self.shadowed[i] = w_value
     self.content[key] = w_value