I think the question is self explanatory.
If I want to execute a program that takes an input from a file, will it execute faster if I import and use sys library rather than fileinput or there will be no difference?
Asked
Active
Viewed 154 times
2

Rory Daulton
- 21,934
- 6
- 42
- 50

Thomas
- 49
- 1
- 9
1 Answers
2
Reading and writing to a disk is thousands of times slower than accessing memory (and that's much slower than accessing the CPU cache or just executing instructions), so it's unlikely that there would be a significant difference unless the library is amazingly inefficient. It's also unlikely that this would be the bottleneck if your program, but you should profile it if you're still concerned.

Community
- 1
- 1

Brendan Long
- 53,280
- 21
- 146
- 188