MCPcopy Index your code
hub / github.com/RustPython/RustPython / detect_builtin_generator_call

Method detect_builtin_generator_call

crates/codegen/src/compile.rs:8305–8327  ·  view source on GitHub ↗
(
        &self,
        func: &ast::Expr,
        args: &ast::Arguments,
    )

Source from the content-addressed store, hash-verified

8303 }
8304
8305 fn detect_builtin_generator_call(
8306 &self,
8307 func: &ast::Expr,
8308 args: &ast::Arguments,
8309 ) -> Option<BuiltinGeneratorCallKind> {
8310 let ast::Expr::Name(ast::ExprName { id, .. }) = func else {
8311 return None;
8312 };
8313 if args.args.len() != 1
8314 || !args.keywords.is_empty()
8315 || !matches!(args.args[0], ast::Expr::Generator(_))
8316 {
8317 return None;
8318 }
8319 match id.as_str() {
8320 "tuple" => Some(BuiltinGeneratorCallKind::Tuple),
8321 "list" => Some(BuiltinGeneratorCallKind::List),
8322 "set" => Some(BuiltinGeneratorCallKind::Set),
8323 "all" => Some(BuiltinGeneratorCallKind::All),
8324 "any" => Some(BuiltinGeneratorCallKind::Any),
8325 _ => None,
8326 }
8327 }
8328
8329 /// Emit the optimized inline loop for builtin(genexpr) calls.
8330 ///

Callers 1

compile_callMethod · 0.80

Calls 4

SomeClass · 0.50
lenMethod · 0.45
is_emptyMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected