@@ -45,7 +45,7 @@ pub struct Context {
45
45
pub int_cache_pool : Vec < PyIntRef > ,
46
46
// there should only be exact objects of str in here, no non-str objects and no subclasses
47
47
pub ( crate ) string_pool : StringPool ,
48
- pub ( crate ) slot_new_wrapper : PyObjectRef ,
48
+ pub ( crate ) slot_new_wrapper : PyRef < PyBuiltinFunction > ,
49
49
pub names : ConstName ,
50
50
}
51
51
@@ -288,11 +288,9 @@ impl Context {
288
288
let names = unsafe { ConstName :: new ( & string_pool, & types. str_type . to_owned ( ) ) } ;
289
289
290
290
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 ( ) ,
293
292
types. builtin_function_or_method_type ,
294
- )
295
- . into ( ) ;
293
+ ) ;
296
294
297
295
let empty_str = unsafe { string_pool. intern ( "" , types. str_type . to_owned ( ) ) } . to_owned ( ) ;
298
296
let empty_bytes = create_object ( PyBytes :: from ( Vec :: new ( ) ) , types. bytes_type ) ;
@@ -491,11 +489,11 @@ impl Context {
491
489
}
492
490
493
491
#[ 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
495
493
where
496
494
F : IntoPyNativeFunc < FKind > ,
497
495
{
498
- PyNativeFuncDef :: new ( f. into_func ( ) , PyStr :: new_ref ( name, self ) )
496
+ PyNativeFuncDef :: new ( f. into_func ( ) , name)
499
497
}
500
498
501
499
#[ inline]
@@ -531,16 +529,17 @@ impl Context {
531
529
}
532
530
533
531
// #[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 >
535
533
where
536
534
F : IntoPyNativeFunc < FKind > ,
537
535
{
538
- self . make_func_def ( name, f) . build_function ( self )
536
+ self . make_func_def ( self . intern_str ( name) , f)
537
+ . build_function ( self )
539
538
}
540
539
541
540
pub fn new_method < F , FKind > (
542
541
& self ,
543
- name : impl Into < PyStr > ,
542
+ name : & ' static PyStrInterned ,
544
543
class : & ' static Py < PyType > ,
545
544
f : F ,
546
545
) -> PyRef < PyBuiltinMethod >
0 commit comments