Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make readonly array through typing only.
As title.
  • Loading branch information
stuartarchibald committed Jun 22, 2022
commit d69a6acd3c2c584d68ad86a59c5ba756fca38ed9
7 changes: 2 additions & 5 deletions numba/np/arrayobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -2589,16 +2589,13 @@ def impl(arr):

@intrinsic
def _force_readonly(tyctx, arr):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to numba.np.unsafe.ndarray?

"""Takes an array, and returns it with the readonly bit set in both typing
and lowering."""
"""Takes an array, and returns it with the readonly bit set through
typing"""
sig = arr.copy(readonly=True)(arr)

def impl(cgctx, builder, sig, llargs):
arrayty = make_array(arr)
array = arrayty(cgctx, builder, llargs[0])
# make readonly hack
parent = array._datamodel.get_type('parent')
setattr(array, 'parent', Constant(cgctx.get_value_type(parent), None))
return impl_ret_borrowed(cgctx, builder, sig.return_type,
array._getvalue())
return sig, impl
Expand Down