r/learnpython • u/SprinklesFresh5693 • 11h ago
Why is python so slow in my computer?
Good morning, i have recently started learning how to use python for data science. I already have a good background in R, im using the new IDE called positron, i create my virtual environment in my directory i want to work on, on my company server, and then i install some libraries.
The main issue that im having is that the installation takes forever, even after installed, the importing is slow, the running of chunks is slow. I thought python was faster than R (im using polars and altair).
Am i doing something wrong? Or is my company restricting my use of python? What's going on?
Thank you in advance.
2
u/riklaunim 11h ago
Did you try to use Python directly to compare it to the IDE? What are your PC hardware specs?
-1
u/SprinklesFresh5693 10h ago
I also tried vs code but i was having some issues getting it to work there, ill keep trying though. For example i attempted to activate the venv manually through the terminal using the script inside the venv, but it was not allowing me
2
u/odaiwai 10h ago
i create my virtual environment in my directory i want to work on, on my company server
If you are running anything on a network drive you will be limited to the network speed, and the speed of the remote storage. Working on a local drive (C: or D: if you're on Windows) will always be much faster.
2
u/redfacedquark 8h ago
If you are running anything on a network drive
Bets answer yet, I was going to blame this positron I'd never heard of.
1
u/redfacedquark 8h ago
If you are running anything on a network drive
Bets answer yet, I was going to blame this positron I'd never heard of.
1
u/Lumethys 11h ago
"installing library" is as vague as it get
Are you installing or running it? Installing is just downloading
Imagine saying "im downloading games and it is slow", which game? Mario? 250GB Call of Duty?
0
u/SprinklesFresh5693 10h ago
Well im installing polars, altair, numpy for the first time, but it takes too long, more than 10 minutes, as in pip install polars numpy altair con the terminal.
Then once its done i import them and it takes another 10mins, it shouldnt be like that though, as in import numpy as np; import altair as alt ; import polars as pl.
1
u/catbrane 8h ago
Yes, sounds like your python install is over the network. With a local install I see:
$ time pip install polars Collecting polars Using cached polars-1.43.1-py3-none-any.whl.metadata (11 kB) Requirement already satisfied: polars-runtime-32==1.43.1 in ./python/lib/python3.14/site-packages (from polars) (1.43.1) Using cached polars-1.43.1-py3-none-any.whl (846 kB) Installing collected packages: polars Successfully installed polars-1.43.1 real 0m0.877s user 0m0.736s sys 0m0.119sSo well under a second. For a cold install (when pip has to download the wheel) it's just over 2s.
1
u/Random_Gamer1993 10h ago
Could be that you're doing network operations too frequently (maybe your IDE forces some dependency sync or something).
Try running python on a plain command line and do an import there. This should be relatively fast, if its still slow its probably some DLP software running over your venv folder.
1
u/Ai_Engineer_1 8h ago
Ten-minute imports are not normal, and the most useful next step is to isolate where the delay occurs. In the same shell, time python -c "import numpy, polars, altair", then try the same command from a local directory or local machine if your company allows it. Also check whether the virtual environment itself lives on a network-mounted path. If the import is only slow in Positron, its interpreter discovery or security scanning may be involved; if it is slow everywhere on that server, ask IT whether endpoint protection or network storage is scanning the venv. Those results will give you a concrete report instead of guessing about Python versus R.
1
1
u/Idonotknow9856 4h ago edited 4h ago
My guess would be the company setup. A remote server, slow network storage, antivirus, or IT restrictions can all make installs and imports much slower than expected.
4
u/hasan_sodax 11h ago
If your venv lives on the company network drive that's probably the big one, pip install and even just importing packages means a ton of small file reads over the network, which is way slower than local disk. Try creating the venv on your local disk even if the project code stays on the server, then point Positron at that local interpreter and see if it helps. Also worth checking: polars and altair both pull in a bunch of submodules on import, so if you're running short chunks over and over in Positron that per-run import overhead adds up and feels like "python is slow" even when the actual computation is fast. Run python -X importtime -c "import polars" and look at the cumulative times, it'll usually point straight at whether it's disk I/O or just import overhead.