Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ code optimization for cleaning special chars from string #2698

Merged
merged 6 commits into from Dec 6, 2023

Conversation

manijhariya
Copy link
Contributor

Reference #2697

Fixes #2697
Optimized code for cleaning strings by removing special chars and extra spaces.

Description:

Current Code:

The existing implementation relies on Python's string replacement feature.

  • It employs a for loop, which may be suboptimal for repeated use of the cleaning function.
  • This could potentially lead to slower execution, especially with long strings or a substantial volume of strings.
Updated Code:

The proposed update utilizes regular expressions with compiled patterns.

  • The For loop has been replaced with a single regex pattern, and the replacement operation is now performed using the regex sub function.
  • the removal of newline characters is achieved with a regex substitution.
  • The updated function, when applied to long strings, achieves the same results in half the time compared to the current implementation.

@manijhariya manijhariya requested a review from a team as a code owner November 11, 2023 07:23
@CLAassistant
Copy link

CLAassistant commented Nov 11, 2023

CLA assistant check
All committers have signed the CLA.

@shir22
Copy link
Contributor

shir22 commented Nov 21, 2023

Hi @manijhariya, many thanks for your contribution! We will review it soon
Please make sure to sign the CLA so it will be mergeable later on

@Nadav-Barak Nadav-Barak added the feature Feature update or code change to the package label Nov 22, 2023
@harsh-deepchecks
Copy link
Contributor

@manijhariya Can you take a look at the pylint issues and resolve them.

@manijhariya
Copy link
Contributor Author

I have update the code removing the issue.

@harsh-deepchecks
Copy link
Contributor

Pylint issue still exists @manijhariya

@noamzbr noamzbr merged commit 6ff7d2a into deepchecks:main Dec 6, 2023
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature update or code change to the package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OPTIMIZATION] function optimization for removing special chars from text.
6 participants