Skip to content

Add wrapper for cocotb.types.Array to coconext binding library #269

@ktbarrett

Description

@ktbarrett

Per #140. We should add a C++ wrapper around the Python Array type. This allows users to use the Python objects directly from C++, avoiding copies like in the type caster, or wrapping/unwrapping in the binding case; which is useful if the use of these values is limited. But it's rarely all that useful.

We should create a new type coconext_nb::pyArray which is a C++ wrapper around cocotb.types.Array. It's interface should mimic DynArray or Array if possible.

coconext_nb::pyArray double_it(nb::pyArray l) {
    nb::pyArray result;
    for (nb::handle h: l)
        result.append(h * nb::int_(2));
    return result;
}

NB_MODULE(my_ext, m) {
    m.def("double_it", &double_it);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions