Skip to content

Commit

Permalink
Simplify and reduce API changes in numba#6334
Browse files Browse the repository at this point in the history
  • Loading branch information
sklam committed Jan 20, 2021
1 parent de3d3f3 commit 47f3019
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions numba/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def get_bound_function(self, builder, obj, ty):
assert self.get_value_type(ty) == obj.type
return obj

def get_getattr(self, builder, typ, attr):
def get_getattr(self, typ, attr):
"""
Get the getattr() implementation for the given type and attribute name.
The return value is a callable with the signature
Expand All @@ -607,8 +607,8 @@ def get_getattr(self, builder, typ, attr):
return None
else:
pyval = getattr(typ.pymod, attr)
llval = self.get_constant_generic(builder, attrty, pyval)
def imp(context, builder, typ, val, attr):
llval = self.get_constant_generic(builder, attrty, pyval)
return impl_ret_borrowed(context, builder, attrty, llval)
return imp

Expand Down
2 changes: 1 addition & 1 deletion numba/core/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ def lower_expr(self, resty, expr):
self.incref(resty, res)
return res
else:
impl = self.context.get_getattr(self.builder, ty, expr.attr)
impl = self.context.get_getattr(ty, expr.attr)
attrty = self.context.typing_context.resolve_getattr(ty,
expr.attr)

Expand Down
2 changes: 1 addition & 1 deletion numba/core/optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def optional_getattr(context, builder, typ, value, attr):
"""
inner_type = typ.type
val = context.cast(builder, value, typ, inner_type)
imp = context.get_getattr(builder, inner_type, attr)
imp = context.get_getattr(inner_type, attr)
return imp(context, builder, inner_type, val, attr)


Expand Down
2 changes: 1 addition & 1 deletion numba/cpython/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def deferred_getattr(context, builder, typ, value, attr):
"""
inner_type = typ.get()
val = context.cast(builder, value, typ, inner_type)
imp = context.get_getattr(builder, inner_type, attr)
imp = context.get_getattr(inner_type, attr)
return imp(context, builder, inner_type, val, attr)

@lower_cast(types.Any, types.DeferredType)
Expand Down
2 changes: 1 addition & 1 deletion numba/np/arrayobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -2421,7 +2421,7 @@ def record_getitem(context, builder, sig, args):
"""
Record.__getitem__ redirects to getattr()
"""
impl = context.get_getattr(builder, sig.args[0], args[1])
impl = context.get_getattr(sig.args[0], args[1])
return impl(context, builder, sig.args[0], args[0], args[1])


Expand Down
2 changes: 1 addition & 1 deletion numba/np/npyimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def cast(self, val, fromty, toty):
# attempt conversion of the real part to the specified type.
# note that NumPy issues a warning in this kind of conversions
newty = fromty.underlying_float
attr = self.context.get_getattr(self.builder, fromty, 'real')
attr = self.context.get_getattr(fromty, 'real')
val = attr(self.context, self.builder, fromty, val, 'real')
fromty = newty
# let the regular cast do the rest...
Expand Down

0 comments on commit 47f3019

Please sign in to comment.