René's URL Explorer Experiment


Title: bpo-44019: Implement operator.call(). by anntzer · Pull Request #27888 · python/cpython · GitHub

Open Graph Title: bpo-44019: Implement operator.call(). by anntzer · Pull Request #27888 · python/cpython

X Title: bpo-44019: Implement operator.call(). by anntzer · Pull Request #27888 · python/cpython

Description: Having operator.call(obj, arg) mean type(obj).__call__(obj, arg) is consistent with the other dunder operators. The semantics with *args, **kwargs then follow naturally from the single-arg semantics. I realize that I proposed different semantics in the original bug report, but that didn't even actually match to the proposed use case; the second proposal in the thread is the correct one. The semantics here work for at least two different use cases that I have seen: Using concurrent.futures.Executor.map on a list of callables (executor.map(operator.call, callables)). In that case the performance doesn't actually matter much and a Python helper would in fact be fine. Loading a "typed" csv file (cf. numpy.loadtxt), where each column has a separate type, e.g. converters = [int, float, int, float] lines = [ # Assume that we already `str.split` them. ["1", "2.2", "3", "4.4"], ["5", "6.6", "7", "8.8"], ] [[*map(operator.call, converters, words)] for words in lines] # faster than the list comprehension [[conv(word) for conv, word in zip(converters, words)] for words in lines] Here the performance actually matters (with numpy, one may easily be loading millions of rows). A simple benchmark gives $ ./python -mtimeit -s 'from operator import call; funcs = [int, float, float, int]; inputs = ["1", "2", "3", "4"]' -- '[*map(call, funcs, inputs)]' 500000 loops, best of 5: 761 nsec per loop $ ./python -mtimeit -s 'from operator import call; funcs = [int, float, float, int]; inputs = ["1", "2", "3", "4"]' -- '[func(inp) for func, inp in zip(funcs, inputs)]' 200000 loops, best of 5: 1.07 usec per loop i.e. map(operator.call, ...) gives a significant speedup. https://bugs.python.org/issue44019

Open Graph Description: Having operator.call(obj, arg) mean type(obj).__call__(obj, arg) is consistent with the other dunder operators. The semantics with *args, **kwargs then follow naturally from the single-arg semanti...

X Description: Having operator.call(obj, arg) mean type(obj).__call__(obj, arg) is consistent with the other dunder operators. The semantics with *args, **kwargs then follow naturally from the single-arg semanti...

Opengraph URL: https://github.com/python/cpython/pull/27888

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8f64fa34-8d6d-2e4e-cd8e-d132d6693bce
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB92A:20CC71:1C97597:26005C3:6A5D5052
html-safe-noncebc1c6681f68411855033cf92802eba8197deaf3e4f3c37e38543bc081e85561b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTJBOjIwQ0M3MToxQzk3NTk3OjI2MDA1QzM6NkE1RDUwNTIiLCJ2aXNpdG9yX2lkIjoiMjAxNDQ0NTI4MTE0OTI3NjI0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac20f1123b33f19471f9de05cc72a4914031aa415bc0889c71565476a0c1a6a981
hovercard-subject-tagpull_request:717303451
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/27888/files
twitter:imagehttps://avatars.githubusercontent.com/u/1322974?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1322974?s=400&v=4
og:image:altHaving operator.call(obj, arg) mean type(obj).__call__(obj, arg) is consistent with the other dunder operators. The semantics with *args, **kwargs then follow naturally from the single-arg semanti...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/27888/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F27888%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F27888%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/27888/files
Reloadhttps://github.com/python/cpython/pull/27888/files
Reloadhttps://github.com/python/cpython/pull/27888/files
Please reload this pagehttps://github.com/python/cpython/pull/27888/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/27888/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.4k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
mdickinsonhttps://github.com/mdickinson
python:mainhttps://github.com/python/cpython/tree/main
anntzer:operator.callhttps://github.com/anntzer/cpython/tree/operator.call
Conversation 23 https://github.com/python/cpython/pull/27888
Commits 3 https://github.com/python/cpython/pull/27888/commits
Checks 0 https://github.com/python/cpython/pull/27888/checks
Files changed https://github.com/python/cpython/pull/27888/files
Please reload this pagehttps://github.com/python/cpython/pull/27888/files
bpo-44019: Implement operator.call(). https://github.com/python/cpython/pull/27888/files#top
Show all changes 3 commits https://github.com/python/cpython/pull/27888/files
344751b bpo-44019: Implement operator.call(). anntzer Aug 22, 2021 https://github.com/python/cpython/pull/27888/commits/344751bede0370c18fc82556782896cd5e20f4cf
de53676 Add whatsnew entry. anntzer Sep 24, 2021 https://github.com/python/cpython/pull/27888/commits/de536767b12a9e6fe21fd620820b8671dc8a72c2
35f5534 Fix whatsnew typo. anntzer Sep 24, 2021 https://github.com/python/cpython/pull/27888/commits/35f5534de61871fbecbd227dfe88053c2a8f295f
Clear filters https://github.com/python/cpython/pull/27888/files
Please reload this pagehttps://github.com/python/cpython/pull/27888/files
Please reload this pagehttps://github.com/python/cpython/pull/27888/files
operator.rst https://github.com/python/cpython/pull/27888/files#diff-b1cdd777fe0413dbc713f9049883e3182e7ed6f39637983e8cf8005f3f7af78e
3.11.rst https://github.com/python/cpython/pull/27888/files#diff-78f24041d66ab8ed2ae1aee94bcd42396d27af833cb96a3c506294c6d6dce82d
operator.py https://github.com/python/cpython/pull/27888/files#diff-2ea92c5fc4c308512ab17f95ccd627a366fbe9d83a618e4f87c1de494117e406
test_operator.py https://github.com/python/cpython/pull/27888/files#diff-0048aaa01dcec5ed2e510294679e9e95e25cebf4e45ba2e6dc75f9ccfbe4b3e3
2021-08-22-13-25-17.bpo-44019.BN8HDy.rst https://github.com/python/cpython/pull/27888/files#diff-e9386dc4d0e8f106f9c0cff7e2f1e48800882ba5068df09063fe566bd32766e5
_operator.c https://github.com/python/cpython/pull/27888/files#diff-3113a72896321417acbbb16a5622a4e98d66b2fba42baf9bd884fc91e16b0844
Doc/library/operator.rsthttps://github.com/python/cpython/pull/27888/files#diff-b1cdd777fe0413dbc713f9049883e3182e7ed6f39637983e8cf8005f3f7af78e
View file https://github.com/anntzer/cpython/blob/35f5534de61871fbecbd227dfe88053c2a8f295f/Doc/library/operator.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/27888/{{ revealButtonHref }}
https://github.com/python/cpython/pull/27888/files#diff-b1cdd777fe0413dbc713f9049883e3182e7ed6f39637983e8cf8005f3f7af78e
https://github.com/python/cpython/pull/27888/files#diff-b1cdd777fe0413dbc713f9049883e3182e7ed6f39637983e8cf8005f3f7af78e
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L116
Doc/whatsnew/3.11.rsthttps://github.com/python/cpython/pull/27888/files#diff-78f24041d66ab8ed2ae1aee94bcd42396d27af833cb96a3c506294c6d6dce82d
View file https://github.com/anntzer/cpython/blob/35f5534de61871fbecbd227dfe88053c2a8f295f/Doc/whatsnew/3.11.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/27888/{{ revealButtonHref }}
https://github.com/python/cpython/pull/27888/files#diff-78f24041d66ab8ed2ae1aee94bcd42396d27af833cb96a3c506294c6d6dce82d
https://github.com/python/cpython/pull/27888/files#diff-78f24041d66ab8ed2ae1aee94bcd42396d27af833cb96a3c506294c6d6dce82d
Lib/operator.pyhttps://github.com/python/cpython/pull/27888/files#diff-2ea92c5fc4c308512ab17f95ccd627a366fbe9d83a618e4f87c1de494117e406
View file https://github.com/anntzer/cpython/blob/35f5534de61871fbecbd227dfe88053c2a8f295f/Lib/operator.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/27888/{{ revealButtonHref }}
https://github.com/python/cpython/pull/27888/files#diff-2ea92c5fc4c308512ab17f95ccd627a366fbe9d83a618e4f87c1de494117e406
https://github.com/python/cpython/pull/27888/files#diff-2ea92c5fc4c308512ab17f95ccd627a366fbe9d83a618e4f87c1de494117e406
https://github.com/python/cpython/pull/27888/files#diff-2ea92c5fc4c308512ab17f95ccd627a366fbe9d83a618e4f87c1de494117e406
https://github.com/python/cpython/pull/27888/files#diff-2ea92c5fc4c308512ab17f95ccd627a366fbe9d83a618e4f87c1de494117e406
Lib/test/test_operator.pyhttps://github.com/python/cpython/pull/27888/files#diff-0048aaa01dcec5ed2e510294679e9e95e25cebf4e45ba2e6dc75f9ccfbe4b3e3
View file https://github.com/anntzer/cpython/blob/35f5534de61871fbecbd227dfe88053c2a8f295f/Lib/test/test_operator.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/27888/{{ revealButtonHref }}
https://github.com/python/cpython/pull/27888/files#diff-0048aaa01dcec5ed2e510294679e9e95e25cebf4e45ba2e6dc75f9ccfbe4b3e3
https://github.com/python/cpython/pull/27888/files#diff-0048aaa01dcec5ed2e510294679e9e95e25cebf4e45ba2e6dc75f9ccfbe4b3e3
Misc/NEWS.d/next/Library/2021-08-22-13-25-17.bpo-44019.BN8HDy.rsthttps://github.com/python/cpython/pull/27888/files#diff-e9386dc4d0e8f106f9c0cff7e2f1e48800882ba5068df09063fe566bd32766e5
View file https://github.com/anntzer/cpython/blob/35f5534de61871fbecbd227dfe88053c2a8f295f/Misc/NEWS.d/next/Library/2021-08-22-13-25-17.bpo-44019.BN8HDy.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/27888/{{ revealButtonHref }}
Modules/_operator.chttps://github.com/python/cpython/pull/27888/files#diff-3113a72896321417acbbb16a5622a4e98d66b2fba42baf9bd884fc91e16b0844
View file https://github.com/anntzer/cpython/blob/35f5534de61871fbecbd227dfe88053c2a8f295f/Modules/_operator.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/27888/{{ revealButtonHref }}
https://github.com/python/cpython/pull/27888/files#diff-3113a72896321417acbbb16a5622a4e98d66b2fba42baf9bd884fc91e16b0844
https://github.com/python/cpython/pull/27888/files#diff-3113a72896321417acbbb16a5622a4e98d66b2fba42baf9bd884fc91e16b0844
https://github.com/python/cpython/pull/27888/files#diff-3113a72896321417acbbb16a5622a4e98d66b2fba42baf9bd884fc91e16b0844
https://github.com/python/cpython/pull/27888/files#diff-3113a72896321417acbbb16a5622a4e98d66b2fba42baf9bd884fc91e16b0844
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.