Write program in python

>Write program in python
>Decide to make it threaded.
>few hours later.
>It dosen't run faster than before.
>Google
>Because of the Global interpreter lock (GIL) python is in reality single threaded no matter how much you use the threading module.

Is this the year 2000? holy shit python get your shit together.

Other urls found in this thread:

cython.org/
youtube.com/watch?v=LMxuDrVs0HE
twitter.com/SFWRedditGifs

You need to enable hardware acceleration for that.

The Global Interpreter Lock is pretty much here to stay. If you really need to, use processes.

>be OP
>be tech illiterate enough to be stumped by this for hours
>not just using processes

Use Perl, it doesn't have a GIL. Shit, even PHP has proper multi-threading these days.

Even if you can run a program multithreaded it doesn't necessarily improve performance. usually unless there is a good reason to go multithreaded or parallel, doing those will decrease performance.

That said, you can disable the GI lock by using a C/C++ library. It's very straightforward to do. Or you can do process level parallization.

Threads are not made to make cpu intensive tasks faster on multicore dumass. Theyre made to access disk while sending data to socket, compute stuff while rendering gui and so on. Use processes along with sockets/queues/pipes to make things multicpu-intensive

Are you sure your program is even CPU-bound? Unless you are doing numerical shit, it probably isn't.

Thanks to the GIL you don't have to give a single flying fuck to inter thread communication, variable access locks and shit like that.

You can spawn 1000 threads where they all use and abuse the same object without giving it a single thought about what could go wrong.

>python

Made the same misstake once. Go Google multiprocessing to sidestep the lock.

Yeah but it's slow. Clojure achieves the same end result with its STM and is faster.

cython.org/

I used this in my bachelor thesis when trying to find out how good idea is to use Python VS Java VS C++ in O(n**5) algorithms in neuro-imagining software.

Cython offers with no hard thinking +40% speed boost (depends on how good your C compiler is). Still it was utter shit, because the same task (only heavy math done in "static" memory):
>Python 6 hours
>Java 1 hour
>C++ 30 seconds.

Cython can maybe solve your problem mate with bullshit tier interpret. Maybe some day Python will learn "just in time" and will be as slow as java.

youtube.com/watch?v=LMxuDrVs0HE

If you're on a unix-y OS and not some shitty ancient OS, you're better off using processes because they're almost as lightweight as threads. It's the unix way

Your fault for using a meme language

Holy shit those numbers. And people doing Java actually ironically claims it's faster than C++.

Just use processes.

>Threads are not made to make cpu intensive tasks faster on multicore dumass. Theyre made to access disk while sending data to socket, compute stuff while rendering gui and so on. Use processes along with sockets/queues/pipes to make things multicpu-intensive
I think you're on the mount stupid about your knowledge of threads.
Threads allow multiple processes to work in the same context (the same data) versus processes that have different contexts, so while your example can be valid uses for threads, you also use threads to make cpu intesive tasks faster on multicore/multithreads processors.
Tasks like compression/decompression (files, pictures, videos), treating large volume of data (XML/HTML parsing), sorting data etc...

Pypy is JIT's python, but it still uses CPython's runtime so it's rarely any faster. The only way Python JIT will become faster is if the entire runtime is re-written in Python. Which is easily 1 million man hours. It will never happen. Python will fade into disuse sometime early 2020's.

Depending on cases, java CAN be faster/just as fast as C/C++ because JIT allows you do optimise in ways that static compilation can't but there are caveats :
- initial execution (before optimisation and JIT kicks in) is always slower, usually more than 10x
- it uses a LOT more RAM
- JVM startup is sloooooooooow
- some things are just slow no matter what (like files, network or system calls)

No. Java is never better, for any purpose. Leave.

thats what you get for wasting your time learning shitty languages user

we all know Shockwave is the future

The point is, each language is good for something.

Python is good for people who never done any programs, but needs to do something fast. Java will never die because EE and everything around it.

Also doing something in C++ takes a lot of skill and time. When you want to build something huge, it is much easier to get 20 average Java developers then 20 C++ developers.

Or anything web related. Writing any kind of CMS in C would be suicide in the long run. Besides the best paid jobs are currently in Java .-)

Threads in python actually makes it slower. Just use processes.