langflow/src/backend/base
Saurabh Misra 214829ab45
refactor: (codeflash)️ Speed up method JSONCleaner._remove_control_characters by 1,491% (#5322)
* ️ Speed up method `JSONCleaner._remove_control_characters` by 1,491%
To optimize the function `_remove_control_characters`, we can use the `translate` method with a translation table to remove control characters. This method is generally faster than using regular expressions for character replacement/removal tasks.

Here is the optimized version of the program.



By precompiling the translation table in the `__init__` method, we're reducing the repeated overhead of creating this table every time `_remove_control_characters` is called. Using `str.translate` with this precompiled table significantly improves the performance compared to using a regular expression substitution.

* add super()

---------

Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
2024-12-18 21:53:59 +00:00
..
langflow refactor: (codeflash)️ Speed up method JSONCleaner._remove_control_characters by 1,491% (#5322) 2024-12-18 21:53:59 +00:00
pyproject.toml feat: add pydantic-ai and update dependencies to support it (#5297) 2024-12-17 05:41:06 -08:00
README.md 1.0 Alpha (#1599) 2024-04-04 02:46:44 -03:00
uv.lock fix: Move crewai to root deps for now (#5204) 2024-12-11 08:15:03 -08:00