Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structref as a mutable struct that is pass-by-ref #5978

Merged
merged 19 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/developer/repomap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ These define aspects of the public Numba interface.
regular functions on the CPU
- :ghfile:`numba/core/extending.py` - Public decorators for extending Numba
(``overload``, ``intrinsic``, etc)
- :ghfile:`numba/core/structref.py` - Public API for defining mutable struct
- :ghfile:`numba/core/structref.py` - Public API for defining a mutable struct
sklam marked this conversation as resolved.
Show resolved Hide resolved
- :ghfile:`numba/core/ccallback.py` - ``@cfunc`` decorator for compiling
functions to a fixed C signature. Used to make callbacks.
- :ghfile:`numba/np/ufunc/decorators.py` - ufunc/gufunc compilation
Expand Down
4 changes: 2 additions & 2 deletions numba/core/types/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def __init__(self, fields):
Parameters
----------
fields : Sequence
A sequence of field description, which is a 2-tuple-like object
A sequence of field descriptions, which is a 2-tuple-like object
containing `(name, type)`, where `name` is a `str` for the field
name, and `type` is a numba type for the field type.
"""
Expand All @@ -733,7 +733,7 @@ def __init__(self, fields):

@property
def field_dict(self):
"""Return a immutable mapping for the field names and their
"""Return an immutable mapping for the field names and their
corresponding types.
"""
return MappingProxyType(dict(self._fields))
Expand Down
6 changes: 3 additions & 3 deletions numba/core/structref.py → numba/experimental/structref.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, context, builder, struct_type):
self.struct_type = struct_type

def new_struct_ref(self, mi):
"""Turn a MemInfo of `StructRefPayload` to a `StructRef`
"""Encapsulate the MemInfo from a `StructRefPayload` in a `StructRef`
"""
context = self.context
builder = self.builder
Expand Down Expand Up @@ -258,7 +258,7 @@ def register(struct_type):
class MyStruct(numba.core.types.StructRef):
... # the simplest subclass can be empty

numba.core.structref.register(MyStruct)
numba.experimental.structref.register(MyStruct)

"""
if struct_type is types.StructRef:
Expand Down Expand Up @@ -360,6 +360,6 @@ def ctor(*args):
def _numba_type_(self):
"""Returns the Numba type instance for this structref instance.

Subclass should NOT override.
Subclasses should NOT override.
"""
return self._type
4 changes: 2 additions & 2 deletions numba/tests/test_struct_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@structref.register
class MySimplerStructType(types.StructRef):
"""
Test associated to this type represent the lowest level uses of structref.
Test associated with this type represent the lowest level uses of structref.
"""
pass

Expand Down Expand Up @@ -64,7 +64,7 @@ class MyStructType(types.StructRef):

# Call to define_proxy is needed to register the use of `MyStruct` as a
# PyObject proxy for creating a Numba-allocated structref.
# The `MyStruct` class and then be used in both jit-code and interpreted-code.
# The `MyStruct` class can then be used in both jit-code and interpreted-code.
structref.define_proxy(
MyStruct,
MyStructType,
Expand Down