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

Don't import pandas #627

Closed
lieryan opened this issue Aug 4, 2021 · 3 comments
Closed

Don't import pandas #627

lieryan opened this issue Aug 4, 2021 · 3 comments

Comments

@lieryan
Copy link

lieryan commented Aug 4, 2021

pandas is really slow to import, importing this library can add seconds to a program's startup time, which can be critical for unittest and CLI programs that needs fast startup time.

To reproduce:

  1. Setup new virtualenv (optional)
  2. Install pandas and pyfakefs into your virtualenv
  3. Time python -c "import pyfakefs.fakefilesysem_unittest"
  4. Compare timing with another virtualenv where pandas is not installed

Expected behaviour:

pyfakefs should only import pandas or other libraries that it monkey patch, if the main application is already importing them. Just having the library installed in the system packages shouldn't cause pyfakefs to assume that the library is going to be used by the currently running application.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Aug 4, 2021
@mrbean-bremen
Copy link
Member

Good point! The import of pandas happens to be able to patch some pandas functionality, which is done by default if pandas is installed. However, there is a possibility to avoid this (using use_known_patches=False), and in this case, there is no need for the import - I can fix this by using a local import only for the patch case.

@mrbean-bremen
Copy link
Member

Please check in current master with use_known_patches=False.

@mrbean-bremen
Copy link
Member

Closing as fixed. Please reopen if you still have issues.

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

No branches or pull requests

2 participants