Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improvement: Assignment string2: str = string1 * N takes a very long time for a large integer N #2616

Closed
@kmr-srbh

Description

@kmr-srbh

N = 106

string1: str = "a"
string2: str = string1 * 10**6

CPython

(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ time python3 ./examples/example.py

real    0m0.038s
user    0m0.021s
sys     0m0.017s

LPython

(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ time ./src/bin/lpython ./examples/example.py

real    0m29.449s
user    0m29.396s
sys     0m0.049s

N = 107

string1: str = "a"
string2: str = string1 * 10**7

CPython

(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ time python3 ./examples/example.py

real    0m0.055s
user    0m0.030s
sys     0m0.025s

LPython (force break)

(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ time ./src/bin/lpython ./examples/example.py
^C
real    9m24.159s
user    9m23.510s
sys     0m0.144s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions