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
  • #3885
Closed
Open
Created Jan 02, 2023 by TopoIogist@TopoIogist

Slow string operations in pypy

I have been revisiting some advent of code examples. For my solution for day 16 from 2016 it seems as pypy 3.9 runs "forever" (left it running for ~10 minutes) while regular python 3.9.4 installation gives the correct result in 13 seconds. Here is the simple code (does not use any libraries, just plain python code):

def dragon(a):
   b = a[::-1].replace('0','r').replace('1','0').replace('r','1')
   return a+'0'+b
def diffstr(a):
   b = ""
   for i in range(0,len(a),2):
      b += ['0','1'][a[i] == a[i+1]]
   return b
def iterdiff(a):
   b = a
   while(len(b) % 2 == 0):
      b = diffstr(b)
   return b

size = 35651584
initstate = '10010000000110000'
while(len(initstate) < size):
   initstate = dragon(initstate)
initstate = initstate[:size]
print(iterdiff(initstate))

Any ideas why it gets stuck? I am running on Windows if that matters.

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