2

I am developing an algorithm. I am using Python and PyCharm for the development. It does not read or write much to persistent storage. Should I put my Python Code onto a SSD instead of my external harddrive? I would think it makes no difference, since the code is loaded into RAM and then my processor and my memory are up. I think https://superuser.com/a/142231 does not apply here, right?

Make42
  • 12,236
  • 24
  • 79
  • 155
  • 2
    Have you been writing any Python scripts that don't load _instantly_, even on a mechanical drive? Measure before optimizing. – TigerhawkT3 Apr 04 '17 at 09:48
  • @TigerhawkT3: I am not familiar with the concept. Can you elaborate on loading instantly / not loading instantly? What do you mean? – Make42 Apr 04 '17 at 09:50
  • 2
    Does anything about it seem slow to you? I have multi-thousand line scripts with barely any noticeable compile/load time. – TigerhawkT3 Apr 04 '17 at 09:51
  • I haven't noticed anything until now. The question was preemptive. – Make42 Apr 04 '17 at 11:29
  • It sounds like you are [prematurely optimizing](http://softwareengineering.stackexchange.com/questions/80084/is-premature-optimization-really-the-root-of-all-evil). – Kara Apr 05 '17 at 18:53

2 Answers2

2

I would like to add an answer here as I see this question interesting and my answer can be very helpful to many. I tried benchmarking between a SSD and HDD with the code below in a python3 terminal

def saved_append():
    seq = range(0, 50000000)
    result = []
    append = result.append
    for elem in seq:
        append(elem)
    return result

x = saved_append()

The speed gap is very huge as I have tested this in two Azure VMS with different resources

| D1_V2 (1vCPU, 3.5GB memory, 2x500 IOPS, 50 GB SSD) | A2 Basic (2vCPU, 3GB, 4x300 IOPS, HDD) |
   4.15s, 3.65s, 3.37s                                  13.07s, 12.02s, 12.20s                                     
Dean Christian Armada
  • 6,724
  • 9
  • 67
  • 116
0

I don't think that it would make to much of a difference. Besides you can change the location of the files generated and used by the python script when you execute the script code.

About the script code itself. Perhaps the startup is a bit slower but not noticeable and only on a very small margin. Before you have multiple Megabytes of python script which have to be executed you will have to type a lot of code and i don't think that is very realistic.

Thomas Nobel
  • 177
  • 1
  • 9
  • As stated in [answer], please avoid answering unclear, overly-broad, typo, opinion-based, unreproducible, or duplicate questions. Write-my-code requests and low-effort homework questions are off-topic for [so] and more suited to professional coding/tutoring services. Good questions adhere to [ask], include a [mcve], have research effort, and have the potential to be useful to future visitors. Answering inappropriate questions harms the site by making it more difficult to navigate and encouraging further such questions, which can drive away other users who volunteer their time and expertise. – TigerhawkT3 Apr 04 '17 at 18:59