Skip to content

opt: remove some generic code bloat#2478

Merged
davidhewitt merged 3 commits intoPyO3:mainfrom
davidhewitt:more-monomorphizations
Jun 25, 2022
Merged

opt: remove some generic code bloat#2478
davidhewitt merged 3 commits intoPyO3:mainfrom
davidhewitt:more-monomorphizations

Conversation

@davidhewitt
Copy link
Member

@davidhewitt davidhewitt commented Jun 25, 2022

Comprised of three commits when just playing around this morning:

  • Use fn instead of closure in LazyStaticType::get_or_init to avoid creating a new monomorphization of GILOnceCell::get_or_init for each PyClass
  • Use fn() instead of impl FnOnce in extract_argument default / from_py_with arguments, reducing number of monomorphizations of those functions. I think this is more correct anyway (we don't need to support capturing closures).
  • Change #[pyclass] machinery to create an iterator of PyClassItems instead of relying on a "visitor" closure. I think it's tidier, and again reduces the amount of code that needs to be generated per PyClass.

Overall this reduced llvm lines by about 2% in the pytests crate.

@davidhewitt davidhewitt enabled auto-merge June 25, 2022 07:46
@davidhewitt davidhewitt force-pushed the more-monomorphizations branch 2 times, most recently from a079a72 to 926e889 Compare June 25, 2022 10:29
@davidhewitt davidhewitt force-pushed the more-monomorphizations branch from 926e889 to 4da9c3a Compare June 25, 2022 21:03
@davidhewitt davidhewitt merged commit 51c0ef5 into PyO3:main Jun 25, 2022
@davidhewitt davidhewitt deleted the more-monomorphizations branch June 25, 2022 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants