Skip to content

bpo-42808: Add PyType_Type.tp_vectorcall for type(obj) performance #24058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 22, 2021

Conversation

sweeneyde
Copy link
Member

@sweeneyde sweeneyde commented Jan 2, 2021

if (!_PyArg_NoKwnames("type", kwnames)) {
return NULL;
}
PyObject *tp = (PyObject *)Py_TYPE(args[0]);
Copy link
Member

@corona10 corona10 Jan 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can use Py_NewRef() in this case?

@github-actions
Copy link

github-actions bot commented Feb 2, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 2, 2021
@sweeneyde
Copy link
Member Author

@markshannon As code owner, do you think there is any worth to this?

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Feb 3, 2021
@markshannon
Copy link
Member

Yes, I do. type(x) is quite common in Python code (unlike the 3 argument form).

@markshannon
Copy link
Member

LGTM. Let's rerun the tests before merging as they are a month old.

@markshannon markshannon closed this Feb 3, 2021
@markshannon markshannon reopened this Feb 3, 2021
@sweeneyde
Copy link
Member Author

Any update on this? I'm seeing some nice benchmarks:

.\python.bat -m pyperf timeit -s "import collections, itertools" "collections.deque(map(type, itertools.repeat(17, 1_000_000)), maxlen=0)"
Before: Mean +- std dev: 26.0 ms +- 0.8 ms
After:  Mean +- std dev: 11.6 ms +- 0.1 ms

.\python.bat -m pyperf timeit "type(17)"
Before: 51.6 ns +- 3.5 ns
After:  33.8 ns +- 2.1 ns

@sweeneyde
Copy link
Member Author

@markshannon Any update on this?

@sweeneyde sweeneyde closed this Feb 22, 2021
@sweeneyde sweeneyde reopened this Feb 22, 2021
Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I will merge this PR after tests are passed ;)
cc @markshannon

@corona10 corona10 self-assigned this Feb 22, 2021
@corona10 corona10 merged commit b19855b into python:master Feb 22, 2021
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL8 3.x has failed when building commit b19855b.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/509/builds/780) and take a look at the build logs.
  4. Check if the failure is related to this commit (b19855b) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/509/builds/780

Summary of the results of the build (if available):

== Tests result: ENV CHANGED ==

411 tests OK.

10 slowest tests:

  • test_concurrent_futures: 3 min 24 sec
  • test_multiprocessing_spawn: 1 min 41 sec
  • test_capi: 1 min 26 sec
  • test_unparse: 1 min 10 sec
  • test_multiprocessing_forkserver: 1 min 7 sec
  • test_gdb: 1 min 6 sec
  • test_peg_generator: 1 min 5 sec
  • test_tokenize: 1 min 2 sec
  • test_asyncio: 58.5 sec
  • test_multiprocessing_fork: 57.0 sec

1 test altered the execution environment:
test_asyncio

14 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_nis
test_ossaudiodev test_startfile test_tix test_tk test_ttk_guionly
test_winconsoleio test_winreg test_winsound test_zipfile64

Total duration: 5 min 44 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/sslproto.py", line 321, in __del__
    self.close()
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/sslproto.py", line 316, in close
    self._ssl_protocol._start_shutdown()
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/sslproto.py", line 590, in _start_shutdown
    self._abort()
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/sslproto.py", line 731, in _abort
    self._transport.abort()
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/selector_events.py", line 680, in abort
    self._force_close(None)
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/selector_events.py", line 731, in _force_close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/base_events.py", line 745, in call_soon
    self._check_closed()
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

@corona10
Copy link
Member

Buildbot failure is unrelated to this PR

@sweeneyde sweeneyde deleted the ttv branch December 19, 2021 05:48
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.

5 participants