Skip to content

gh-162350: Use AC vectorcall for map() - #162457

Open
eendebakpt wants to merge 3 commits into
python:mainfrom
eendebakpt:map-ac-vectorcall
Open

eendebakpt wants to merge 3 commits into
python:mainfrom
eendebakpt:map-ac-vectorcall

Conversation

@eendebakpt

@eendebakpt eendebakpt commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replace the hand-written tp_new and vectorcall of map with Argument Clinic generated code.

  • This improves performance only for passing the strict keyword, e.g. map(..., strict=True).
  • Passing fewer than two positional arguments now raises map() takes at least 2 positional arguments (N given) instead of map() must have at least two arguments.
  • Using AC reduces the manual code written
  • Docstrings reworded because clinic insists on a one-line summary

Quick benchmarks (noisy machine)

Benchmark main branch
map(f, t1) 92.8 ns 90.2 ns 1.03x faster
map(g, t1, t1, t1) 118 ns 123 ns 1.04x slower
map(f, t1, strict=True) 277 ns 121 ns 2.29x faster
SubMap(f, t1) 140 ns 143 ns 1.02x slower
list(map(f, t10)) 290 ns 303 ns 1.04x slower
zip(t1, t1) (control) 117 ns 122 ns 1.04x slower
Benchmark script (script as in the file)

Generated with help from Claude Code.

eendebakpt and others added 3 commits November 22, 2026 20:40
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant