Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 673
    • Issues 673
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #3591
Closed
Open
Created Nov 02, 2021 by Maciej Fijalkowski@fijalOwner

urllib.request.urlopen a lot slower than cpython

This is the benchmark:

import time
try:
    from urllib.request import urlopen
except ImportError:
    from urllib import urlopen

try:
    clock = time.process_time
except:
    clock = time.clock

l = []
for _ in range(10):
    t0 = clock()
    for i in range(100):
        urlopen("https://www.python.org")
    t1 = clock()
    print("Next: %.2f" % (t1 - t0))
    l.append(t1-t0)
print("Average: %.2f" % (sum(l)/len(l)))

For my setup the answer is around 4x slower than cpython (experiment-with-ffi-addresses helps around 10%) on py3.7 branch.

The issues are:

  • indiscrimante use of memoryview in httplib
  • recv_into being slow
  • intermediate raw buffers allocated and not freed on time (neither memory pressure is increased nor they're freed in time) in _io module
  • possibly more
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking