Skip to content

Commit

Permalink
refactor: improve forth comments
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Sep 13, 2022
1 parent 94f9e79 commit ec8390c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/python/forth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,19 @@ py::object machine_bytecodes_at_to_python_content(std::shared_ptr<ak::ForthMachi
auto bytecodes_capsule = capsule_for_shared_pointer(bytecodes_holder);
auto offsets_capsule = capsule_for_shared_pointer(offsets_holder);

// Create buffers from typed pointers and lifetime capsules
auto bytecodes_array = py::array_t<I>(bytecodes_holder->size(), bytecodes_holder->data(), bytecodes_capsule);
auto offsets_array = py::array_t<int64_t>(offsets_holder->size(), offsets_holder->data(), offsets_capsule);

// Build Python objects for buffers
auto layout_content = py::module::import("awkward").attr("contents").attr("NumpyArray")(bytecodes_array);
auto layout_offsets = py::module::import("awkward").attr("index").attr("Index64")(offsets_array);

auto layout = py::module::import("awkward").attr("contents").attr("ListOffsetArray")(
layout_offsets, layout_content
);

// Extract the given offset
return layout.attr("_getitem_at")(index);
}

Expand Down

0 comments on commit ec8390c

Please sign in to comment.