Skip to content

Commit 99f9b41

Browse files
committed
Simplify
1 parent 23d72c2 commit 99f9b41

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

core/src/G3Pipeline.cxx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,19 @@ G3Pipeline_halt_processing()
360360
G3Pipeline::halt_processing = true;
361361
}
362362

363+
static py::list G3Module_Process(G3Module &mod, G3FramePtr ptr)
364+
{
365+
std::deque<G3FramePtr> queue;
366+
py::list vec;
367+
368+
mod.Process(ptr, queue);
369+
370+
for (auto i = queue.begin(); i != queue.end(); i++)
371+
vec.append(*i);
372+
373+
return vec;
374+
}
375+
363376
// Python Process() has a different API from the C++ version, since we have
364377
// variable return types. It is passed the frame, but returns its output:
365378
// - If it returns None, the input frame is pushed to the output (usual case)
@@ -375,9 +388,6 @@ G3Pipeline_halt_processing()
375388
class G3PythonModule : public G3Module
376389
{
377390
public:
378-
G3PythonModule() {};
379-
virtual ~G3PythonModule() {};
380-
381391
py::object Process(G3FramePtr frame) {
382392
PYBIND11_OVERRIDE_PURE(py::object, G3PythonModule, Process, frame);
383393
}
@@ -411,17 +421,10 @@ PYBINDINGS("core", scope) {
411421
register_class<G3Module, G3PythonModule>(scope, "G3Module",
412422
"Base class for functors that can be added to a G3Pipeline.")
413423
.def(py::init<>())
414-
.def("Process", [](G3Module &mod, G3FramePtr ptr) {
415-
std::deque<G3FramePtr> queue;
416-
py::list vec;
417-
mod.Process(ptr, queue);
418-
for (auto fr: queue)
419-
vec.append(fr);
420-
return vec;
421-
}, "Process the input frame. See documentation for valid return types.")
422-
.def("__call__", [](py::object &self, G3FramePtr ptr) {
423-
return self.attr("Process")(ptr);
424-
}, "Process the input frame. See documentation for valid return types.")
424+
.def("Process", &G3Module_Process,
425+
"Process the input frame. See documentation for valid return types.")
426+
.def("__call__", &G3Module_Process,
427+
"Process the input frame. See documentation for valid return types.")
425428
.def_property_readonly_static("__g3module__",
426429
[](py::object){ return true; });
427430
;

0 commit comments

Comments
 (0)