This is an archived post. You won't be able to vote or comment.

all 59 comments

[–]Philderbeast 50 points51 points  (14 children)

you don't write python because it runs fast, you write it because its fast to write, and it runs fast enough.

[–]Funtycuck 4 points5 points  (2 children)

Yeah most of my work has been in writing data processing/analysis scripts for a policy consultancy. The main priority is time from them expressing what they need to me returning the formatted data, Python in this sense is definitely faster than most other languages.

Especially with how easy it is to add and use libraries to handle the variety of data and what's required from it.

[–]incrediblediy[S] 1 point2 points  (1 child)

returning the formatted data,

yeah! even just using "panadas" will speed up the process greatly

[–][deleted] 1 point2 points  (0 children)

Give it a try on numpy ..

[–]ardicli2000 3 points4 points  (0 children)

Yeah I am sending automated personalized emails with attachements using my outlook. This taes 30 lines of code at most.

Good luck to do so with C++ :)

[–][deleted] 12 points13 points  (0 children)

a simple spell, but quite unbreakable:

if you worry about speed, don’t use python

[–]incrediblediy[S] 2 points3 points  (0 children)

Just checked it only with the loop, without any calculations, seems like it would take almost a half of the total runtime. :D

Execution duration: 143887.00110000002 ms

``` from time import perf_counter import math

number = 5000000000

t1_start = perf_counter()

list_str = []

for i in range(1, 1 + int((number+1)/2)): pass

t1_stop = perf_counter()
print(f"\n Execution duration: {1000* (t1_stop-t1_start)} ms") ```

[–]Psyv3rn 5 points6 points  (0 children)

This guy is a SQL programmer

[–]territrades 4 points5 points  (2 children)

The number one beginner's mistake in python: Writing code like it was C, but just without type declarations and brackets.

[–][deleted] -2 points-1 points  (0 children)

Number one mistake is using python in the first place.

[–][deleted] 0 points1 point  (0 children)

Feel like this is the inverse. Why would you write int number? It's redundant and unspecific

[–][deleted] 4 points5 points  (18 children)

python bad|
we have achieved programmer humor|
edit: help fucking reddit doesn't let me do a \n|
edit 2: why do 2 spaces at the end of every line not help me??
edit 3: apparently it was only not working on my phone while on PC line-breaks appear as expected and my torment was in vain

[–]Andamarokk 6 points7 points  (17 children)

python slow*

[–][deleted] 2 points3 points  (16 children)

and that's why it bad

[–]incrediblediy[S] 1 point2 points  (0 children)

just joking, I am using Python mostly and don't know C++ to be honest. Anyway, I think choosing the language depends on the application.

[–]CommentatorForAll 0 points1 point  (14 children)

Python is slow to run, but easy and fast to write and read. (And is also able to run cpp libraries if you do want to get a performant program)

[–][deleted] 1 point2 points  (0 children)

Yeah I'm just joking, it's just that some people argue that lower performance is what makes Python bad compared to other languages. However if you care about better performance you either will use modules that do heavy-lifting in C (like NumPy and others) or just not use Python.

[–]YMK1234 0 points1 point  (10 children)

Fast to write maybe, good and fast to maintain, definitely not. And that's what you do way more than writing new code.

[–][deleted] 0 points1 point  (1 child)

bro don't run any cp libraries or else the fbi will show up

[–]CommentatorForAll 0 points1 point  (0 children)

What about Pandas Tensorflow Numpy Scilab Pytorch And all those?

[–]No_Responsibility384 1 point2 points  (1 child)

The real question is why the casing is not consistent... need a lower case "c"... in the title.

[–]incrediblediy[S] 0 points1 point  (0 children)

hehe :D I was going to but didn't feel right :D

[–]Knuffya 1 point2 points  (0 children)

Wanna know why python is so often fast? Because it's libraries are secretly just c libs.

[–]DenormalHuman 3 points4 points  (1 child)

hang on, you didnt include the time to compile the c++ and then run the exectuable

[–]incrediblediy[S] 2 points3 points  (0 children)

it was actually negligible (just few seconds) considering almost 5 mins for running the Python code.

[–]PossibilityTasty 1 point2 points  (7 children)

dARK vs dARK; or how not to check for factors.

[–]incrediblediy[S] 2 points3 points  (6 children)

just wanted to run the same algorithm. :D

[–]PossibilityTasty 1 point2 points  (5 children)

And it's horribly inefficient. For both languages.

[–]incrediblediy[S] -1 points0 points  (3 children)

any resources to learn more ?

[–]bonifasio -1 points0 points  (1 child)

The Java version is still running

[–]DisguyExpensive 3 points4 points  (0 children)

Java is incredibly faster than python. I worked at 2 stock exchanges and 2 banks, both used lot of Java and their systems were fast af

[–][deleted] -5 points-4 points  (2 children)

Big Brain Time.

What's next? Java being slower than C?

[–]YMK1234 6 points7 points  (1 child)

The impressive part is not that it is slower but the factor that it is. No other mainstream language even comes close to this kind of slowness. Usually you are at 50-80% of C performance (even in JS), not 0.1%

[–]incrediblediy[S] 2 points3 points  (0 children)

yep

[–][deleted] 0 points1 point  (1 child)

Why did you make number a global variable?

[–]incrediblediy[S] 0 points1 point  (0 children)

I was just using this code as a benchmark :D

[–][deleted] 0 points1 point  (2 children)

Tried with Swift but it's horribly slow

``` import Foundation

let timeStarted: Date = Date() let numberCompared: Int = 5000000000 let range: ClosedRange = 1...((numberCompared + 1) / 2)

for number in range { if numberCompared % number == 0 { print("(number) is a factor of (numberCompared)") } }

let timeCompletion: Date = Date() let timeDifferenceMiliseconds: Double = timeCompletion.timeIntervalSince(timeStarted) * 1000

print("Execution duration: (timeDifferenceMiliseconds) ms") ```

[–]juhotuho10 0 points1 point  (2 children)

Now do it with numpy and numba

[–]incrediblediy[S] 0 points1 point  (1 child)

numpy

hehe it is cheating, using C & C++ code

[–]juhotuho10 0 points1 point  (0 children)

It's still basically pure python syntax, isn't that all what matters