# Comparison between time taken in Python and Julia

**URL:** <https://discourse.julialang.org/t/comparison-between-time-taken-in-python-and-julia/28159>\
**Category:** Machine Learning\
**Created:** [August 29, 2019, 11:08am UTC](https://discourse.julialang.org/t/comparison-between-time-taken-in-python-and-julia/28159 "2019-08-29T11:08:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![richie96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/richie96/32/9353_2.png) [@richie96](https://discourse.julialang.org/u/richie96)\
**Post date:** [August 29, 2019, 11:08am UTC](https://discourse.julialang.org/t/comparison-between-time-taken-in-python-and-julia/28159/1 "2019-08-29T11:08:14Z")

</div>

Hi,

I am doing a comparison between Python and Julia by analyzing the same data set.  
I am using a data set containing nearly 800,000 rows of data. I load the data from two csv files containing equal amount of data each and then merge them together.  
I applied Random Forest algorithm to the data.  
Given below is the time the python and julia code took to do the same tasks.

Loading Data: Python - 2.195s  
Julia - 15.232s

Merging data: Python - 0.1505s  
Julia - 5.55s

Prediction time: Python - 10.2617s  
Julia - 24.5291s

Visualization: Python - 0.3434s  
Julia - 35.338s

Can anyone help me in understanding why Julia is so much slower compared to Python in the above mentioned tasks.

Thanks.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 29, 2019, 11:15am UTC](https://discourse.julialang.org/t/comparison-between-time-taken-in-python-and-julia/28159/2 "2019-08-29T11:15:48Z")

</div>

> [@richie96](#):
>
> Can anyone help me in understanding why Julia is so much slower compared to Python in the above mentioned tasks.

Probably not without your code.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 29, 2019, 11:39am UTC](https://discourse.julialang.org/t/comparison-between-time-taken-in-python-and-julia/28159/3 "2019-08-29T11:39:04Z")

</div>

> [@richie96](#):
>
> Visualization: Python - 0.3434s  
> Julia - 35.338s

I’m guessing that this means you are including loading/compilation time. When you launch Julia and load a plotting package (e.g. `using Plots`) and run your first plot (e.g. `plot(...)`), you spend a lot of time waiting for everything to compile, after which point the code is fast.

Compilation time is irrelevant for large computational tasks because it scales with the code size, not the computation time. That is, if you are running something for an hour, waiting 30 seconds to compile at the beginning is irrelevant.

For interactive usage, the compilation delay is annoying, and is something that will be improved in future Julia versions — it’s just a matter of caching compiled code, nothing fundamental. However, for interactive exploration I would typically recommend just opening a [Jupyter notebook](https://github.com/JuliaLang/IJulia.jl), loading `Plots` and whatever other modules you need, and leaving the notebook open as you work (creating and evaluating new notebook cells as needed). If you are working interactively for more than a few minutes, a 30s delay at the beginning quickly becomes irrelevant.

(Even if you are doing development work, the [Revise package](https://github.com/timholy/Revise.jl) means that you rarely need to restart an interactive Julia session.)
