1- use super :: { type_, PyClassMethod , PyStaticMethod , PyStr , PyStrRef , PyType } ;
1+ use super :: { type_, PyClassMethod , PyStaticMethod , PyStr , PyStrInterned , PyStrRef , PyType } ;
22use crate :: {
33 builtins:: PyBoundMethod ,
44 class:: PyClassImpl ,
@@ -10,12 +10,12 @@ use std::fmt;
1010
1111pub struct PyNativeFuncDef {
1212 pub func : PyNativeFunc ,
13- pub name : PyStrRef ,
13+ pub name : & ' static PyStrInterned ,
1414 pub doc : Option < PyStrRef > ,
1515}
1616
1717impl PyNativeFuncDef {
18- pub fn new ( func : PyNativeFunc , name : PyStrRef ) -> Self {
18+ pub fn new ( func : PyNativeFunc , name : & ' static PyStrInterned ) -> Self {
1919 Self {
2020 func,
2121 name,
@@ -122,7 +122,7 @@ impl PyBuiltinFunction {
122122 }
123123 #[ pygetset( magic) ]
124124 fn name ( & self ) -> PyStrRef {
125- self . value . name . clone ( )
125+ self . value . name . to_owned ( )
126126 }
127127 #[ pygetset( magic) ]
128128 fn qualname ( & self ) -> PyStrRef {
@@ -217,7 +217,7 @@ impl Callable for PyBuiltinMethod {
217217
218218impl PyBuiltinMethod {
219219 pub fn new_ref < F , FKind > (
220- name : impl Into < PyStr > ,
220+ name : & ' static PyStrInterned ,
221221 class : & ' static Py < PyType > ,
222222 f : F ,
223223 ctx : & Context ,
@@ -236,7 +236,7 @@ impl PyBuiltinMethod {
236236impl PyBuiltinMethod {
237237 #[ pygetset( magic) ]
238238 fn name ( & self ) -> PyStrRef {
239- self . value . name . clone ( )
239+ self . value . name . to_owned ( )
240240 }
241241 #[ pygetset( magic) ]
242242 fn qualname ( & self ) -> String {
@@ -260,7 +260,7 @@ impl PyBuiltinMethod {
260260 ) -> ( Option < PyObjectRef > , ( Option < PyObjectRef > , PyStrRef ) ) {
261261 let builtins_getattr = vm. builtins . get_attr ( "getattr" , vm) . ok ( ) ;
262262 let classname = vm. builtins . get_attr ( & self . class . __name__ ( vm) , vm) . ok ( ) ;
263- ( builtins_getattr, ( classname, self . value . name . clone ( ) ) )
263+ ( builtins_getattr, ( classname, self . value . name . to_owned ( ) ) )
264264 }
265265}
266266
0 commit comments