Skip to content

Conversation

@Falanty
Copy link

@Falanty Falanty commented Nov 3, 2025

Problem

In JavaScript, the operation * of a number and a string that cannot be parsed into a number results in NaN, whereas in Python, the result is a string consisting of the original string repeated by the number used in the operation.
This discrepency in operator behaviour between the languages can cause memory issues, if the resulting string is very large.

Solution

This PR aims to eliminate the problematic case and improve the behaviour simulation of JavaScript for the * operation while not impeding the performance.

Refactor Suggestion

As there are also differences in behaviour for various other operators, a refactor of the compute_operators function could be considered. A PoC, that computes the operators via JavaScript using PyMiniRacer can be found here: main...Falanty:DoubleX:feat/js_operator_calculation_with_js_context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant