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 668
    • Issues 668
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Mercurial Paris conference scheduled ! Main event : 2022-09-22. Call for papers deadline: 2022-06-17.

  • PyPy
  • pypypypy
  • Issues
  • #1790

Closed
Open
Created Jun 14, 2014 by Bitbucket Importer@bitbucket_importerMaintainer

numpy.empty 1800x slower than CPython; numpy.zeros 10x slower

Created originally on Bitbucket by Crusader Ky (crusaderky)

numpy.empty currently zeros out the memory in pypy. In cpython, it obviously doesn't. There's a lot of situations I can think of where you don't care about memory initialisation, e.g. when you're allocating the memory for a C or OpenCL function to write to.

On very small arrays, pypy is faster than cpython:

timeit('np.empty((5,), dtype=np.float64)', setup='import numpy as np', number=1000000) CPython: 0.48946094512939453 PyPy: 0.21847295761108398

timeit('np.zeros((5,), dtype=np.float64)', setup='import numpy as np', number=1000000) CPython: 0.4740109443664551 PyPy: 0.20502209663391113

On large ones (4MB), however, CPython wins by a large gulf:

timeit('np.empty((500000,), dtype=np.float64)', setup='import numpy as np', number=1000) CPython: 0.000637054443359375 PyPY: 1.1482269763946533 (1800x slower)

timeit('np.zeros((500000,), dtype=np.float64)', setup='import numpy as np', number=1000) CPython: 0.13871288299560547 PyPy: 1.2538270950317383 (10x slower)

Tests run on CPython 2.7.6 + numpy-1.8.1 vs pypy-c-jit-71909-2d96616d4fd6-linux64 + latest numpy fork from git.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking