>conjures up a solution to a problem in 10 minutes
heh.. nothing personnel, kiddo..
>conjures up a solution to a problem in 10 minutes
heh.. nothing personnel, kiddo..
Wtf, there's children in your code. Are you some sort of sex slave satanist?
I let the play with my python if you know what I mean
>import solution.py
>l-look i'm a r-real programmer
>if you know what I mean
I really don't
Not a weeb, but chop sticks are comfy.
> hours of debugging because tabs, white space and else statements tabbed left
>Global Interpreter Lock
>"hah, look at you morons. Spending 30 seconds to solve a very simple problem. I'm superior because I spend 3 hours hand building the tool that will solve the solution! Hahahaha!"
Then lets see you compute and sum the primes under 2 million, OP. You're on the clock from this post
C > python. Pythonnis written in C. Python is good for scripting quicking things. Like hello world and horseshit like that. Ever heard of widely used python daemons?
Do you know what python is most useful for? Getting a job. Nothing that you sorry NEETs would understand
Except a lot of applications at work are rarely performance critical to the point that a few milliseconds makes a difference, but having a SWE spend a few minutes on it rather than a few hours is a much bigger benefit. No one is using python for performance, they use it because you can be extremely productive with it.
>Then lets see you compute and sum the primes under 2 million, OP
This isn't a real world problem unless you're some sort of data scientist. When OP says Python solution is 10 minutes, he's probably referring to every day problems like automating SysAdmin tasks
We can argue all day about semantics (scripting vs programming), but at the end of the day we're writing code that instructs a machine to do work for us. Call it whatever you want :)
if __name__ == "__main__":
primesum = 0
y = 0
sieve = {}
for i in range(0, 2000000):
sieve[i] = True
sieve[0] = False
sieve[1] = False
for i in range(0, 2000000):
if sieve[i]:
primesum += i
y = i
while (y < 2000000):
sieve[y] = False
y += i
print ("The sum is {0}".format(primesum))
Are you saying you cannot write a trivial sieve? It's a few LoC in Python, you could have done it instead of typing up these posts
>asks question that implies python has bad performance
>gets told why that isn't the point
>hurr you can't do x
figures someone who's adamant on one language and not using the right tool for a problem is retarded.
>you can be extremely productive with it
I'm sorry, but for intensive tasks Python is so ass-slow you actually save time rewriting your shit in C.
Did you know that
for i in range(0, 2000000):
Can be written as:
for i in range(2000000):
Because the 0 is the default
My God, absolutely horrific. Why are you using a dict instead of an array? Why are you using a while loop to mark off composites? Why are you using python2?
Your code:
$ time python test.py
The sum is 142913828922
real 0m2.364s
user 0m2.288s
sys 0m0.076s
What I wrote off the top of my head (still not optimal, especially memory-wise, char array would be better):
def sieve(limit):
if limit >= 2:
yield 2
primes = [1]*limit
for i in range(3, limit, 2):
if primes[i]:
yield i
for j in range(i*i, limit, i):
primes[j] = 0
print(sum(sieve(2*10**6)))
$ time python3 test2.py
142913828922
real 0m0.368s
user 0m0.360s
sys 0m0.008s
>Why are you using a dict instead of an array?
Based on his code I'm guessing he's a C programmer who's trying to use Python, but hasn't yet realized that they're different languages
>pajeet as fuck
>Python is only good for scripting things quickly
That's why services such as YouTube, Dropbox, PayPal, Twilio and so many other large players just "quickly scripted" their entire core functionality with it and regularly give talks to show NEETs like you how to properly use it at scale. You've obviously never managed a large C codebase.
What runs under python? What is apache written in? What is the kernel written? You just listed webapps. It doesn't compare to the robust strength of C. Also, python doesn't scale that well. Google, and the others, will eventually replace python with go, retard. Why don't start learning that meme?
Matlab is better anyway, the solution is probably implemented already and you just need to find it in the excellent documentation.
Pajeet still has a job, unlike you. Soon he will be able to buy his own street for shitting. What will you have? Nothing. NOTHING.
I use graphite at work to store half a million metrics every minutes.
It's made with python and the performances are shit, someone made a Go version that runs 6 times faster but I can't switch at this stage of the project.
Why the hell would someone chose a low performance language for a program that will obviously needs a fuckton operations every seconds ...
Thank God my needs are small enough that I don't have to make a cluster for it
it's still very possible for a go implementation to be slower than python because the libraries aren't mature