Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

ToJSCode method is too slow #28

@ilikhotk

Description

@ilikhotk

ToJSCode method uses a very inefficient way of concatenating strings: it uses += operator. For "toy" strings this is ok, but when strings get very large, this method takes an excruciatingly long amount of time (hours) to complete. Fortunately, it is easily fixable: put all sub-strings into a list and return a join of them at the end of the function.

Python uses C-style strings: concatenating them with + operator is extremely inefficient since it takes time just to find the end of the string (\0 character) where the concatenation should take place. This is why ''.join(some_list) is much (orders of magnitude) faster than concatenating with + operator.

If possible, please implement this quick fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions