8000 fn class #[inline] (#5846) · RustPython/RustPython@f0c7cb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0c7cb2

Browse files
authored
fn class #[inline] (#5846)
1 parent 0095941 commit f0c7cb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+61
-0
lines changed

derive-impl/src/pypayload.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub(crate) fn impl_pypayload(input: DeriveInput) -> Result<TokenStream> {
77

88
let ret = quote! {
99
impl ::rustpython_vm::PyPayload for #ty {
10+
#[inline]
1011
fn class(_ctx: &::rustpython_vm::vm::Context) -> &'static rustpython_vm::Py<::rustpython_vm::builtins::PyType> {
1112
<Self as ::rustpython_vm::class::StaticType>::static_type()
1213
}

vm/src/builtins/asyncgenerator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct PyAsyncGen {
2121
type PyAsyncGenRef = PyRef<PyAsyncGen>;
2222

2323
impl PyPayload for PyAsyncGen {
24+
#[inline]
2425
fn class(ctx: &Context) -> &'static Py<PyType> {
2526
ctx.types.async_generator
2627
}
@@ -141,6 +142,7 @@ impl Unconstructible for PyAsyncGen {}
141142
#[derive(Debug)]
142143
pub(crate) struct PyAsyncGenWrappedValue(pub PyObjectRef);
143144
impl PyPayload for PyAsyncGenWrappedValue {
145+
#[inline]
144146
fn class(ctx: &Context) -> &'static Py<PyType> {
145147
ctx.types.async_generator_wrapped_value
146148
}
@@ -190,6 +192,7 @@ pub(crate) struct PyAsyncGenASend {
190192
}
191193

192194
impl PyPayload for PyAsyncGenASend {
195+
#[inline]
193196
fn class(ctx: &Context) -> &'static Py<PyType> {
194197
ctx.types.async_generator_asend
195198
}
@@ -283,6 +286,7 @@ pub(crate) struct PyAsyncGenAThrow {
283286
}
284287

285288
impl PyPayload for PyAsyncGenAThrow {
289+
#[inline]
286290
fn class(ctx: &Context) -> &'static Py<PyType> {
287291
ctx.types.async_generator_athrow
288292
}

vm/src/builtins/bool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl PyObjectRef {
8181
pub struct PyBool;
8282

8383
impl PyPayload for PyBool {
84+
#[inline]
8485
fn class(ctx: &Context) -> &'static Py<PyType> {
8586
ctx.types.bool_type
8687
}

vm/src/builtins/bytearray.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ pub struct PyByteArrayIterator {
884884
}
885885

886886
impl PyPayload for PyByteArrayIterator {
887+
#[inline]
887888
fn class(ctx: &Context) -> &'static Py<PyType> {
888889
ctx.types.bytearray_iterator_type
889890
}

vm/src/builtins/bytes.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl AsRef<[u8]> for PyBytesRef {
7878
}
7979

8080
impl PyPayload for PyBytes {
81+
#[inline]
8182
fn class(ctx: &Context) -> &'static Py<PyType> {
8283
ctx.types.bytes_type
8384
}
@@ -683,6 +684,7 @@ pub struct PyBytesIterator {
683684
}
684685

685686
impl PyPayload for PyBytesIterator {
687+
#[inline]
686688
fn class(ctx: &Context) -> &'static Py<PyType> {
687689
ctx.types.bytes_iterator_type
688690
}

vm/src/builtins/classmethod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl From<PyObjectRef> for PyClassMethod {
4141
}
4242

4343
impl PyPayload for PyClassMethod {
44+
#[inline]
4445
fn class(ctx: &Context) -> &'static Py<PyType> {
4546
ctx.types.classmethod_type
4647
}

vm/src/builtins/code.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl fmt::Debug for PyCode {
214214
}
215215

216216
impl PyPayload for PyCode {
217+
#[inline]
217218
fn class(ctx: &Context) -> &'static Py<PyType> {
218219
ctx.types.code_type
219220
}

vm/src/builtins/complex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl PyComplex {
3434
}
3535

3636
impl PyPayload for PyComplex {
37+
#[inline]
3738
fn class(ctx: &Context) -> &'static Py<PyType> {
3839
ctx.types.complex_type
3940
}

vm/src/builtins/coroutine.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct PyCoroutine {
1717
}
1818

1919
impl PyPayload for PyCoroutine {
20+
#[inline]
2021
fn class(ctx: &Context) -> &'static Py<PyType> {
2122
ctx.types.coroutine_type
2223
}
@@ -127,6 +128,7 @@ pub struct PyCoroutineWrapper {
127128
}
128129

129130
impl PyPayload for PyCoroutineWrapper {
131+
#[inline]
130132
fn class(ctx: &Context) -> &'static Py<PyType> {
131133
ctx.types.coroutine_wrapper_type
132134
}

vm/src/builtins/dict.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ macro_rules! dict_view {
823823
}
824824

825825
impl PyPayload for $iter_name {
826+
#[inline]
826827
fn class(ctx: &Context) -> &'static Py<PyType> {
827828
ctx.types.$iter_class
828829
}
@@ -896,6 +897,7 @@ macro_rules! dict_view {
896897
}
897898

898899
impl PyPayload for $reverse_iter_name {
900+
#[inline]
899901
fn class(ctx: &Context) -> &'static Py<PyType> {
900902
ctx.types.$reverse_iter_class
901903
}

vm/src/builtins/enumerate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct PyEnumerate {
2222
}
2323

2424
impl PyPayload for PyEnumerate {
25+
#[inline]
2526
fn class(ctx: &Context) -> &'static Py<PyType> {
2627
ctx.types.enumerate_type
2728
}
@@ -92,6 +93,7 @@ pub struct PyReverseSequenceIterator {
9293
}
9394

9495
impl PyPayload for PyReverseSequenceIterator {
96+
#[inline]
9597
fn class(ctx: &Context) -> &'static Py<PyType> {
9698
ctx.types.reverse_iter_type
9799
}

vm/src/builtins/filter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct PyFilter {
1414
}
1515

1616
impl PyPayload for PyFilter {
17+
#[inline]
1718
fn class(ctx: &Context) -> &'static Py<PyType> {
1819
ctx.types.filter_type
1920
}

vm/src/builtins/float.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ impl PyFloat {
3333
}
3434

3535
impl PyPayload for PyFloat {
36+
#[inline]
3637
fn class(ctx: &Context) -> &'static Py<PyType> {
3738
ctx.types.float_type
3839
}

vm/src/builtins/function.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ impl PyFunction {
376376
}
377377

378378
impl PyPayload for PyFunction {
379+
#[inline]
379380
fn class(ctx: &Context) -> &'static Py<PyType> {
380381
ctx.types.function_type
381382
}
@@ -791,6 +792,7 @@ impl PyBoundMethod {
791792
}
792793

793794
impl PyPayload for PyBoundMethod {
795+
#[inline]
794796
fn class(ctx: &Context) -> &'static Py<PyType> {
795797
ctx.types.bound_method_type
796798
}
@@ -823,6 +825,7 @@ pub(crate) struct PyCell {
823825
pub(crate) type PyCellRef = PyRef<PyCell>;
824826

825827
impl PyPayload for PyCell {
828+
#[inline]
826829
fn class(ctx: &Context) -> &'static Py<PyType> {
827830
ctx.types.cell_type
828831
}

vm/src/builtins/generator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct PyGenerator {
2020
}
2121

2222
impl PyPayload for PyGenerator {
23+
#[inline]
2324
fn class(ctx: &Context) -> &'static Py<PyType> {
2425
ctx.types.generator_type
2526
}

vm/src/builtins/genericalias.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl fmt::Debug for PyGenericAlias {
4949
}
5050

5151
impl PyPayload for PyGenericAlias {
52+
#[inline]
5253
fn class(ctx: &Context) -> &'static Py<PyType> {
5354
ctx.types.generic_alias_type
5455
}

vm/src/builtins/getset.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl std::fmt::Debug for PyGetSet {
3939
}
4040

4141
impl PyPayload for PyGetSet {
42+
#[inline]
4243
fn class(ctx: &Context) -> &'static Py<PyType> {
4344
ctx.types.getset_type
4445
}

vm/src/builtins/int.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ where
4848
}
4949

5050
impl PyPayload for PyInt {
51+
#[inline]
5152
fn class(ctx: &Context) -> &'static Py<PyType> {
5253
ctx.types.int_type
5354
}

vm/src/builtins/iter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pub struct PySequenceIterator {
184184
}
185185

186186
impl PyPayload for PySequenceIterator {
187+
#[inline]
187188
fn class(ctx: &Context) -> &'static Py<PyType> {
188189
ctx.types.iter_type
189190
}
@@ -247,6 +248,7 @@ pub struct PyCallableIterator {
247248
}
248249

249250
impl PyPayload for PyCallableIterator {
251+
#[inline]
250252
fn class(ctx: &Context) -> &'static Py<PyType> {
251253
ctx.types.callable_iterator
252254
}

vm/src/builtins/list.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl FromIterator<PyObjectRef> for PyList {
5050
}
5151

5252
impl PyPayload for PyList {
53+
#[inline]
5354
fn class(ctx: &Context) -> &'static Py<PyType> {
5455
ctx.types.list_type
5556
}
@@ -538,6 +539,7 @@ pub struct PyListIterator {
538539
}
539540

540541
impl PyPayload for PyListIterator {
542+
#[inline]
541543
fn class(ctx: &Context) -> &'static Py<PyType> {
542544
ctx.types.list_iterator_type
543545
}
@@ -583,6 +585,7 @@ pub struct PyListReverseIterator {
583585
}
584586

585587
impl PyPayload for PyListReverseIterator {
588+
#[inline]
586589
fn class(ctx: &Context) -> &'static Py<PyType> {
587590
ctx.types.list_reverseiterator_type
588591
}

vm/src/builtins/map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct PyMap {
1616
}
1717

1818
impl PyPayload for PyMap {
19+
#[inline]
1920
fn class(ctx: &Context) -> &'static Py<PyType> {
2021
ctx.types.map_type
2122
}

vm/src/builtins/mappingproxy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ unsafe impl Traverse for MappingProxyInner {
3636
}
3737

3838
impl PyPayload for PyMappingProxy {
39+
#[inline]
3940
fn class(ctx: &Context) -> &'static Py<PyType> {
4041
ctx.types.mappingproxy_type
4142
}

vm/src/builtins/memory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ impl Hashable for PyMemoryView {
10371037
}
10381038

10391039
impl PyPayload for PyMemoryView {
1040+
#[inline]
10401041
fn class(ctx: &Context) -> &'static Py<PyType> {
10411042
ctx.types.memoryview_type
10421043
}

vm/src/builtins/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub struct PyModule {
5454
}
5555

5656
impl PyPayload for PyModule {
57+
#[inline]
5758
fn class(ctx: &Context) -> &'static Py<PyType> {
5859
ctx.types.module_type
5960
}

vm/src/builtins/namespace.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::{
1818
pub struct PyNamespace {}
1919

2020
impl PyPayload for PyNamespace {
21+
#[inline]
2122
fn class(ctx: &Context) -> &'static Py<PyType> {
2223
ctx.types.namespace_type
2324
}

vm/src/builtins/object.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use itertools::Itertools;
2222
pub struct PyBaseObject;
2323

2424
impl PyPayload for PyBaseObject {
25+
#[inline]
2526
fn class(ctx: &Context) -> &'static Py<PyType> {
2627
ctx.types.object_type
2728
}

vm/src/builtins/property.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct PyProperty {
2525
}
2626

2727
impl PyPayload for PyProperty {
28+
#[inline]
2829
fn class(ctx: &Context) -> &'static Py<PyType> {
2930
ctx.types.property_type
3031
}

vm/src/builtins/range.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub struct PyRange {
6868
}
6969

7070
impl PyPayload for PyRange {
71+
#[inline]
7172
fn class(ctx: &Context) -> &'static Py<PyType> {
7273
ctx.types.range_type
7374
}
@@ -533,6 +534,7 @@ pub struct PyLongRangeIterator {
533534
}
534535

535536
impl PyPayload for PyLongRangeIterator {
537+
#[inline]
536538
fn class(ctx: &Context) -> &'static Py<PyType> {
537539
ctx.types.long_range_iterator_type
538540
}
@@ -598,6 +600,7 @@ pub struct PyRangeIterator {
598600
}
599601

600602
impl PyPayload for PyRangeIterator {
603+
#[inline]
601604
fn class(ctx: &Context) -> &'static Py<PyType> {
602605
ctx.types.range_iterator_type
603606
}

vm/src/builtins/set.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ impl fmt::Debug for PyFrozenSet {
153153
}
154154

155155
impl PyPayload for PySet {
156+
#[inline]
156157
fn class(ctx: &Context) -> &'static Py<PyType> {
157158
ctx.types.set_type
158159
}
159160
}
160161

161162
impl PyPayload for PyFrozenSet {
163+
#[inline]
162164
fn class(ctx: &Context) -> &'static Py<PyType> {
163165
ctx.types.frozenset_type
164166
}
@@ -1295,6 +1297,7 @@ impl fmt::Debug for PySetIterator {
12951297
}
12961298

12971299
impl PyPayload for PySetIterator {
1300+
#[inline]
12981301
fn class(ctx: &Context) -> &'static Py<PyType> {
12991302
ctx.types.set_iterator_type
13001303
}

vm/src/builtins/singletons.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{
1212
pub struct PyNone;
1313

1414
impl PyPayload for PyNone {
15+
#[inline]
1516
fn class(ctx: &Context) -> &'static Py<PyType> {
1617
ctx.types.none_type
1718
}
@@ -77,6 +78,7 @@ impl AsNumber for PyNone {
7778
pub struct PyNotImplemented;
7879

7980
impl PyPayload for PyNotImplemented {
81+
#[inline]
8082
fn class(ctx: &Context) -> &'static Py<PyType> {
8183
ctx.types.not_implemented_type
8284
}

vm/src/builtins/slice.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct PySlice {
2222
}
2323

2424
impl PyPayload for PySlice {
25+
#[inline]
2526
fn class(ctx: &Context) -> &'static Py<PyType> {
2627
ctx.types.slice_type
2728
}
@@ -302,6 +303,7 @@ impl Representable for PySlice {
302303
pub struct PyEllipsis;
303304

304305
impl PyPayload for PyEllipsis {
306+
#[inline]
305307
fn class(ctx: &Context) -> &'static Py<PyType> {
306308
ctx.types.ellipsis_type
307309
}

vm/src/builtins/staticmethod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct PyStaticMethod {
1414
}
1515

1616
impl PyPayload for PyStaticMethod {
17+
#[inline]
1718
fn class(ctx: &Context) -> &'static Py<PyType> {
1819
ctx.types.staticmethod_type
1920
}

0 commit comments

Comments
 (0)
0