@@ -45,7 +45,7 @@ pub struct Context {
4545 pub int_cache_pool : Vec < PyIntRef > ,
4646 // there should only be exact objects of str in here, no non-str objects and no subclasses
4747 pub ( crate ) string_pool : StringPool ,
48- pub ( crate ) slot_new_wrapper : PyObjectRef ,
48+ pub ( crate ) slot_new_wrapper : PyRef < PyBuiltinFunction > ,
4949 pub names : ConstName ,
5050}
5151
@@ -288,11 +288,9 @@ impl Context {
288288 let names = unsafe { ConstName :: new ( & string_pool, & types. str_type . to_owned ( ) ) } ;
289289
290290 let slot_new_wrapper = create_object (
291- PyNativeFuncDef :: new ( PyType :: __new__. into_func ( ) , names. __new__ . to_owned ( ) )
292- . into_function ( ) ,
291+ PyNativeFuncDef :: new ( PyType :: __new__. into_func ( ) , names. __new__ ) . into_function ( ) ,
293292 types. builtin_function_or_method_type ,
294- )
295- . into ( ) ;
293+ ) ;
296294
297295 let empty_str = unsafe { string_pool. intern ( "" , types. str_type . to_owned ( ) ) } . to_owned ( ) ;
298296 let empty_bytes = create_object ( PyBytes :: from ( Vec :: new ( ) ) , types. bytes_type ) ;
@@ -491,11 +489,11 @@ impl Context {
491489 }
492490
493491 #[ inline]
494- pub fn make_func_def < F , FKind > ( & self , name : impl Into < PyStr > , f : F ) -> PyNativeFuncDef
492+ pub fn make_func_def < F , FKind > ( & self , name : & ' static PyStrInterned , f : F ) -> PyNativeFuncDef
495493 where
496494 F : IntoPyNativeFunc < FKind > ,
497495 {
498- PyNativeFuncDef :: new ( f. into_func ( ) , PyStr :: new_ref ( name, self ) )
496+ PyNativeFuncDef :: new ( f. into_func ( ) , name)
499497 }
500498
501499 #[ inline]
@@ -531,16 +529,17 @@ impl Context {
531529 }
532530
533531 // #[deprecated]
534- pub fn new_function < F , FKind > ( & self , name : impl Into < PyStr > , f : F ) -> PyRef < PyBuiltinFunction >
532+ pub fn new_function < F , FKind > ( & self , name : & str , f : F ) -> PyRef < PyBuiltinFunction >
535533 where
536534 F : IntoPyNativeFunc < FKind > ,
537535 {
538- self . make_func_def ( name, f) . build_function ( self )
536+ self . make_func_def ( self . intern_str ( name) , f)
537+ . build_function ( self )
539538 }
540539
541540 pub fn new_method < F , FKind > (
542541 & self ,
543- name : impl Into < PyStr > ,
542+ name : & ' static PyStrInterned ,
544543 class : & ' static Py < PyType > ,
545544 f : F ,
546545 ) -> PyRef < PyBuiltinMethod >
0 commit comments