MCPcopy Index your code
hub / github.com/python/mypy / custom_op

Function custom_op

mypyc/primitives/registry.py:261–298  ·  view source on GitHub ↗

Create a one-off CallC op that can't be automatically generated from the AST. Most arguments are similar to method_op().

(
    arg_types: list[RType],
    return_type: RType,
    c_function_name: str,
    error_kind: int,
    var_arg_type: RType | None = None,
    truncated_type: RType | None = None,
    ordering: list[int] | None = None,
    extra_int_constants: list[tuple[int, RType]] | None = None,
    steals: StealsDescription = False,
    is_borrowed: bool = False,
    *,
    is_pure: bool = False,
    returns_null: bool = False,
)

Source from the content-addressed store, hash-verified

259
260
261def custom_op(
262 arg_types: list[RType],
263 return_type: RType,
264 c_function_name: str,
265 error_kind: int,
266 var_arg_type: RType | None = None,
267 truncated_type: RType | None = None,
268 ordering: list[int] | None = None,
269 extra_int_constants: list[tuple[int, RType]] | None = None,
270 steals: StealsDescription = False,
271 is_borrowed: bool = False,
272 *,
273 is_pure: bool = False,
274 returns_null: bool = False,
275) -> CFunctionDescription:
276 """Create a one-off CallC op that can't be automatically generated from the AST.
277
278 Most arguments are similar to method_op().
279 """
280 if extra_int_constants is None:
281 extra_int_constants = []
282 return CFunctionDescription(
283 "<custom>",
284 arg_types,
285 return_type,
286 var_arg_type,
287 truncated_type,
288 c_function_name,
289 error_kind,
290 steals,
291 is_borrowed,
292 ordering,
293 extra_int_constants,
294 0,
295 is_pure=is_pure,
296 returns_null=returns_null,
297 dependencies=None,
298 )
299
300
301def custom_primitive_op(

Callers 9

generic_ops.pyFile · 0.90
int_ops.pyFile · 0.90
dict_ops.pyFile · 0.90
str_ops.pyFile · 0.90
list_ops.pyFile · 0.90
exc_ops.pyFile · 0.90
misc_ops.pyFile · 0.90
bytes_ops.pyFile · 0.90
tuple_ops.pyFile · 0.90

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…