@@ -200,18 +200,32 @@ CompiledFunction::TraceForKey* getTraceFor(CompiledFunction& fn,
200
200
201
201
} // anonymous namespace
202
202
203
+ static py::tuple tuple_tail (const py::tuple & tup) {
204
+ py::tuple r (tup.size () - 1 );
205
+ for (int i = 1 ; i < tup.size (); i++) {
206
+ r[i-1 ] = tup[i];
207
+ }
208
+ return r;
209
+ }
210
+
203
211
void initCompilerMixin (PyObject *module) {
204
212
auto m = py::handle (module).cast <py::module>();
205
213
py::class_<CompiledFunction>(m, " CompiledFunction" , py::dynamic_attr ())
206
214
.def (py::init<int , bool , bool , py::object, std::string>())
207
- .def (" __call__" , [](CompiledFunction& fn, py::args args) -> py::object {
208
- return fn.call (args);
215
+ .def (" __call__" , [](py::args args_) -> py::object {
216
+ auto fn = py::cast<CompiledFunction*>(args_[0 ]);
217
+ auto args = tuple_tail (args_);
218
+ return fn->call (args);
209
219
})
210
- .def (" has_trace_for" , [](CompiledFunction& fn, py::args args) -> bool {
211
- return getTraceFor (fn, args) != nullptr ;
220
+ .def (" has_trace_for" , [](py::args args_) -> bool {
221
+ auto fn = py::cast<CompiledFunction*>(args_[0 ]);
222
+ auto args = tuple_tail (args_);
223
+ return getTraceFor (*fn, args) != nullptr ;
212
224
})
213
- .def (" graph_for" , [](CompiledFunction& fn, py::args args) -> py::object {
214
- auto trace = getTraceFor (fn, args);
225
+ .def (" graph_for" , [](py::args args_) -> py::object {
226
+ auto fn = py::cast<CompiledFunction*>(args_[0 ]);
227
+ auto args = tuple_tail (args_);
228
+ auto trace = getTraceFor (*fn, args);
215
229
return trace ? py::cast (trace->graph_ ) : py::none ();
216
230
})
217
231
.def (" clear_cache" , [](CompiledFunction& fn) {
0 commit comments