Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 707
    • Issues 707
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • 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
  • PyPyPyPy
  • pypypypy
  • Issues
  • #3733
Closed
Open
Issue created Apr 30, 2022 by Peter Taraba@pepe78

random.randrange seem to slow down going from pypy2 to pypy3 - performance bottleneck

I wrote a very simple code to test out how pypy / python and other languages perform with dictionary operations (insertion). PyPy was performing great in version 2. Now I tried version 3 and performance is significantly worse.

Code:

from datetime import datetime
import random

dic = {}
letter = 'qwertyuiopasdfghjklz'
for i in range(5000001):
    if i%1000000==0:
        now = datetime.now()
        print(str(now))

    s = ""
    for j in range(50):
        s += letter[random.randrange(20)]
    dic[s] = True

Performance with pypy2 & pypy3:

pypy2 (under 2 seconds):

Python 2.7.18 (8e99af2f9b8e, Apr 02 2022, 14:58:34)

[PyPy 7.3.9 with GCC 11.2.0]

2022-04-30 17:01:52.787058

2022-04-30 17:01:54.112563

2022-04-30 17:01:55.492501

2022-04-30 17:01:56.991456

2022-04-30 17:01:58.374874

2022-04-30 17:01:59.701933

pypy3 (around 5 seconds):

Python 3.8.13 (4b1398fe9d76, Apr 02 2022, 15:38:25)

[PyPy 7.3.9 with GCC 11.2.0]

2022-04-30 17:02:11.642042

2022-04-30 17:02:16.627821

2022-04-30 17:02:21.754386

2022-04-30 17:02:27.061380

2022-04-30 17:02:32.320464

2022-04-30 17:02:37.413582

This was on Linux: Manjaro Linux x86_64, kernel: 5.15.32-1-MANJARO, CPU: AMD Ryzen 5 3600X (12) @ 3.800GHz (but other linuxes it's around the same)

software I use to compare languages: https://github.com/pepe78/python-performance

more details: https://www.frisky.world/2022/04/does-this-mean-pypy-is-going-to-slow.html

Edited May 01, 2022 by Matti Picus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking