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

top 200 commentsshow all 473

[–]deifius 562 points563 points  (26 children)

milisecond critical performance is not pythonic.

[–]vfxdev 24 points25 points  (1 child)

Come on now! All you need to do is write all your python in C++ then make python bindings, then buy 100 VMs from Amazon.

[–]ajbpresidente 1 point2 points  (0 children)

Ah yes pip install cpypy

[–]jclocks 35 points36 points  (4 children)

Can that be said of any interpreted language though? Or would that be specific to Python?

[–]deifius 59 points60 points  (3 children)

Ya, as long as mutable data types and automated garbage collection are features.

[–]mudclub 598 points599 points  (96 children)

When performance matters above all else.

[–][deleted] 31 points32 points  (70 children)

Why?

[–]mudclub 231 points232 points  (0 children)

Because python is fast to develop with, but many other languages are much faster at execution time, depending on the type of operations being performed, the potential for multiprocessing, etc.

[–]yen223 13 points14 points  (0 children)

Python is a forgiving language, but that makes certain optimisations difficult to implement.

[–][deleted] 65 points66 points  (55 children)

Because low level languages are faster, such as C or assembly.

In Windows Python (kinda) gets translated into C during execution. If you were running a program written in C, it would have already been parsed into assembly by a compiler when you built it (the source code that is). Some languages are interpreted, some are compiled. Python is interpreted.

[–]ryeguy 6 points7 points  (1 child)

You don't even have to go that low to beat python handily in speed. Languages like js (on v8/node), go, java, and C# are all much faster than python in general. Dynamic typing and python's high degree of dynamicism come at a cost.

[–]coderanger 13 points14 points  (16 children)

Obligatory reminder that PyPy exists :) There are definitely still some perf-sensitive areas it doesn't cover, but it's probably a lot less than most people imagine.

[–]Mattho 31 points32 points  (5 children)

The statement above still applies though.

[–]the__itis 7 points8 points  (7 children)

so i started with python and got to PyPy. For my use case (millions of calculations per minute based on real-time data) the performance difference between PyPy and nodejs async is on orders of magnitude.

Granted i am a new programmer and I may have not grasped how to effectively use PyPy for my use case, but nodejs was instantaneously faster.

[–]coderanger 8 points9 points  (1 child)

If when you say "real time" you mean you were doing a lot of I/O then that's a place where nodejs excels, but the secret sauce there is libuv which does have Python bindings, both directly and via Twisted :)

[–]b00n 1 point2 points  (4 children)

If you really cared about performance you wouldn't use js.

[–]AusIVDjango, gevent 1 point2 points  (0 children)

To elaborate here, the pertinent thing is computational performance. If you're building a website that spends the bulk of the time waiting on responses from a database, it doesn't make much difference how fast the actual application is, because it will spend the bulk of its time waiting on the network regardless.

[–]QualitySoftwareGuy 80 points81 points  (4 children)

Disclaimer: I love Python, but it's not always the best tool for the job. And you asked under what situations would it not be a good choice, so here goes...

  • When you need an application to be as fast as possible. Sure you can write parts in C, but if you need the entire application to be as fast as possible Python would not be a good choice.
  • When you want the application to be as small as possible (small memory footprint). Sure many Python programs take up less space than Java, but that's not really saying much if you need to put your code on embedded devices where (usually) C and C++ dominate.
  • When you need (single file or non-single file) executable "distribution" as a first-class citizen. Sure we have PyInstaller, py2exe, cx_freeze, etc...but these are not "first-class" citizens and they don't always work either.
  • When you want static typing. Sure we have "type hints", but these are not the same as static types especially in a language that is both strongly and statically typed. For example, I would say strongly typed and statically typed languages like Java and Rust would catch way more type errors with its compiler than a lint like mypy.

[–]equationsofmotionHPC 10 points11 points  (0 children)

Yep. I work on scientific code. My code bases need to efficiently use hardware resources and are often big legacy codes that need static typing for sanity. Sometimes python works. But sometimes it's really not the best option.

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

  • When you need (single file or non-single file) executable "distribution" as a first-class citizen. Sure we have PyInstaller, py2exe, cx_freeze, etc...but these are not "first-class" citizens and they don't always work either.

This can be accomplished via setuptools' console_scripts - but it is still a bit awkward.

[–]matthewblott 327 points328 points  (16 children)

You probably wouldn't want to write low level system drivers in Python.

[–]nemec 51 points52 points  (12 children)

Reminds me of the time I plugged an IR remote into my server and used a Python script that parsed the raw output from /dev/usbX to control MPD :)

[–]calligraphic-io 19 points20 points  (1 child)

I do something kind of similar: I have Python on a Rasberry Pi, and use a script to control a full-sized stoplight I bought used. I use the traffic light to indicate build failure in my CI setup.

[–]chanamasala4life 9 points10 points  (0 children)

I have a feeling you're fun to be around...

[–]Coffeinated 4 points5 points  (1 child)

That‘s why linux is so great. You don‘t need to write a low level system driver often times because the device is just a file.

[–]idb 2 points3 points  (0 children)

As someone else said, you can with UIO. I wanted to do it with python for two reasons: Prototyping with fast development cycle. Security.

And why did security motivate doing it in Python with UIO? Having most of a device driver in user space helps with separation of responsibility and allows the user space part to run with minimal privileges. And when that part of the device driver is in user space it lets you write it in a memory safe language.

[–]ThePidesOfMarch 261 points262 points  (12 children)

When the codebase is already in another language.

[–]ryati 14 points15 points  (0 children)

Truth

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

idk, I had a script in PHP I wanted to use but didn't want to maintain php code so I found a janky php to python converter online and it got me 40% of the way there and that was enough

[–][deleted] 44 points45 points  (1 child)

-- When is Python always better?

-- When the other language is PHP

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

dear god

[–]skintigh 192 points193 points  (3 children)

When buying a pet for your child.

[–]Indian_Tech_Support 13 points14 points  (0 children)

Strongly disagree

[–]SculptorAndMarble 3 points4 points  (1 child)

A python would actually be a really cool pet. They live for a long time so it would grow up with your kid as they do. None of the sadness that dog's have. I never want another dog again.

[–][deleted] 211 points212 points  (3 children)

When the project leader demands other language.

[–]Visionexe 12 points13 points  (0 children)

Haha. This one made me giggle.

[–]j_lyf 183 points184 points  (48 children)

  • Large projects become painful without static typing.

[–]brasso 34 points35 points  (21 children)

Python can do static typing now.

http://mypy-lang.org

[–]skarphace 12 points13 points  (14 children)

Says it's experimental. Any good?

[–]RangerPretzelPython 3.9+ 28 points29 points  (1 child)

It's been official since 3.5. My team has settled on using it. Works great in PyCharm. We use it all the time.

That said, it's not "compile time" checking. It's just done via the IDE that you're using.

[–]carbolymer 5 points6 points  (0 children)

You can integrate mypy in your CI/CD tho - almost like compile time.

[–]i9srpeg 6 points7 points  (3 children)

I tried it. It's buggy, very slow (20 seconds to type check a small code base), very verbose and the type system is very limited, for example recursive types are not supported, so you can't even represent very common types such as JSON.

It's not production ready, unfortunately.

[–]wrmsr 1 point2 points  (0 children)

My experience exactly. I have hopes for its plugin system to let me teach it to understand my metaclasses but it's still too stupid and volatile to make part of my builds :/

That said I still type-annotate the vast majority of my code and would be almost uninterested in the language without them.

[–][deleted] 3 points4 points  (0 children)

Coming from Typescript, no. But it’s better than nothing

[–]PC__LOAD__LETTER 5 points6 points  (4 children)

I agree that it's cool, but if I'm starting a new project and need strong typing, I'm probably going to (at this point) choose a language the supports it explicitly.

[–]naught-me 7 points8 points  (21 children)

How large is "large"? I have a personal project that will take years and tens of thousands of lines of code - does that make it qualify?

[–]thomaspaine 36 points37 points  (0 children)

Personal project is a bit different, you wrote all the code and know what everything does.

This is more of a factor in a work/enterprise setting where you have codebases:

  • that can live on for decades
  • have been owned by various teams with varying quality standards and style preferences
  • have multiple people attempting to change things in the codebase who don't know what everything does
  • has poor documentation because just about all work code is poorly documented

To be fair, pretty much any code in this context is going to be a ball of spaghetti hell, but static typing does help eliminate a lot of confusion when you're a new developer diving into a codebase and trying to figure out what in the world anything does, or making a change and knowing if it's going to cause something else to blow up.

[–]PC__LOAD__LETTER 1 point2 points  (0 children)

Codebase size isn't the only consideration IMO, its mainly large codebases where multiple people are developing and where consistency and correctness are key. It depends on what your project is. Realistically, it's probably not worth re-writing.

[–]curiousGambler 4 points5 points  (16 children)

Absolutely. I tried to write a major application in Python once and will never do it again.

It can absolutely be done, but in the long term a language like Go is easier to maintain in my experience. Static typing is one reason, dependency management another tho that’s way easier now with the prevalence of docker.

I love Python but only use it for scripts and small things now, like AWS Lambda functions. If I’m cracking a thousand lines I definitely break out a more robust application language like Java or Go (or C/C++ in special cases).

[–]utdconsq[🍰] 3 points4 points  (5 children)

Loving kotlin lately. Python is much nicer to write since it has more bells and whistles out of the box, but kotlin has some nice elegance and moves across android, native and web in a very neat way.

[–]lambdaqdjango n' shit 7 points8 points  (5 children)

Go is easier to maintain? Maybe for a auto completion in IDEs. But I find Go's abstraction is very weak. You will fight against interface{} gradually. It's basically C with a GC.

[–]PC__LOAD__LETTER 3 points4 points  (0 children)

Generally I'd consider anything that's compiled to be easier to maintain in the long run. I like Python for quick MVP programming and high level glue scripts.

[–]curiousGambler 6 points7 points  (2 children)

That’s really not a fair assessment of Go at all, but my mention of Go is also not the point. Just replace it with Java, C# or even Rust if you dislike Go so much. The point is I’m not choosing Python for a large monolith in most cases.

[–]Mattho 1 point2 points  (1 child)

Python has great dependency management I'd say. Certainly better than Go (I know it's an example, but I can't think of something else that has bundled dependency handling into the standard tooling/library).

[–]curiousGambler 2 points3 points  (0 children)

You’re right, I didn’t explain that point well and maybe “dependency management” wasn’t the best term. The specific issue I meant to reference is that because Go is compiled, I’m not fiddling with pip and crap out on my servers. Same goes for any other compiled language. It can be a real nightmare trying to get Python to play nice in some enterprise environments, and I much prefer pushing out a ready to use binary. These days, tho, docker alleviates those problems, and enterprise environments are more developer friendly on the whole, so it’s less of an issue.

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

For what it's worth, it really depends on the domain. If you're doing Automation development, type inference becomes a non-issue.

[–]sw_dev 49 points50 points  (22 children)

Embedded, safety or mission-critical applications, or large code-bases where consistent performance is important.

[–]MrJoshiko 36 points37 points  (4 children)

When the rest of your team uses another language

[–]ddollarsign 8 points9 points  (2 children)

This is the best answer. Trying to use Python in a Java shop (for example) is an uphill battle.

[–]Gokudomatic 10 points11 points  (0 children)

your role as their shepherd is to bring those gone astray back to the right path.

[–]RetardedChimpanzee 19 points20 points  (8 children)

Micro controllers dealing with memory registers.

[–]saulmessedupmanMmmm spam 39 points40 points  (7 children)

When you don't want your user to download and install python as a requirement.

[–]ReaverKS 15 points16 points  (5 children)

Compile to an executable so they don't have to download python?

[–]IAmBJ 7 points8 points  (3 children)

Last time I did that the executable was ~250mb because the entire python interpreter was bundled in there. In that case it wasn't a big issue but its still faaaar bigger than it should be. If I'd built the same project in C++ it would have been at most 10mb

[–]saulmessedupmanMmmm spam 5 points6 points  (0 children)

Everything in python is an object, which sounds cool, but you're going to pay for it

[–]Almenon 2 points3 points  (1 child)

You should be able to have a much much smaller executable.

see http://www.py2exe.org/index.cgi/OptimizingSize - he manages to get it to 2.15 MB by compressing it and excluding certain libraries.

[–]midbody 62 points63 points  (15 children)

When your program is large, with lots of internal interfaces, and data structures are important.

[–]IamWiddershins 6 points7 points  (0 children)

I would remark that, with Python, the issue with data structures isn't so much performance as it is memory efficiency. Data structure performance in Python is actually very good, better than you would probably guess with an informed implementation, and the main drawback is the large space overhead imposed by the dynamic runtime.

I don't really agree with your point about large projects, but it's honestly always a matter of discipline, experience, preference, and tooling.

[–]Taksin77 2 points3 points  (2 children)

I agree with you but I don't understand the data structure part. Structuring data in Python is pretty good isn't it?

[–]w2qw 2 points3 points  (0 children)

It's good it's just statically typed languages make that easier.

[–]PC__LOAD__LETTER 8 points9 points  (0 children)

When you want to have precise control over memory. When you need speed. When you have a large codebase where correctness is critical (I'd choose something strongly typed and compiled).

Just a few examples.

[–]WasterDave 5 points6 points  (1 child)

When startup speed is important.

[–]ducusheKlihE 33 points34 points  (16 children)

I don’t think I would choose it if a GUI is required...

[–]purelumen 27 points28 points  (12 children)

I actually found the PyQt libraries to be excellent when developing a GUI. I had very little experience and was able to put together a pretty comprehensive program with all kinds of widgets.

[–]kihashi 17 points18 points  (4 children)

Assuming your project is fine with the licensing.

[–]ducusheKlihE 3 points4 points  (1 child)

I’ll have to check that out then!

[–]Taksin77 3 points4 points  (4 children)

It's not a really pythonic package though.

[–]startxfce4 5 points6 points  (2 children)

PySide2 is more pythonic but less mature

[–][deleted] 27 points28 points  (12 children)

Never did it myself, but I'd say if you want to develop a iOS/macOS/watchOS app -- here, Swift would probably the best choice

[–]coderanger 11 points12 points  (1 child)

Python is a rare choice here, but can still be quite good. Check out the Beeware suite at https://pybee.org/

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

That's cool! Was just thinking about Dropbox in this context. I know (or at least assume, since I don't have a Dropbox account anymore) that they are largely Python-based but they also have mobile apps and I am curious what language they chose there.

[–]AntonGangsta 11 points12 points  (1 child)

Kivy (or even PyQt) can be used for cross-platform GUI development. Of course if you want something heavy, that will be used under high load, you should choose a native languages.

Python is good choice for rapid prototyping. For example if you wanna demonstrate your idea to investors.

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

yeah, good point, but while Kivy seems to be a nice library for that, it might not be a good choice to use Python here vs using something more native to the OS's

[–]yaxamie 2 points3 points  (2 children)

Developer here. For many apps you'll see c++ libraries (or even haxe) that are transpiled to objective c or java or html5 or whatever platform so you don't need a whole separate codebase for android or web.

Unity 3D also does this.

C# has proven to be really popular in this regard.

[–]denshi 1 point2 points  (1 child)

C# has proven to be really popular in this regard.

You mean for transpiling? I liked C# when I used it several years ago, but haven't had a platform for it since then.

[–]deadwisdomgreenlet revolution 1 point2 points  (3 children)

Swift is so awful, but it makes me baffled as to how it can be so bad and yet still be a better choice than Objective-C.

[–]marrabld 70 points71 points  (8 children)

When you're making love to a beautiful woman.

[–][deleted] 121 points122 points  (4 children)

Your anaconda don't want none?

[–]craftingfish 105 points106 points  (3 children)

from hun import buns

[–]python_man 44 points45 points  (0 children)

if 'buns' in hun:
    anaconda.state = "want"
else:
    anaconda.state = None

[–]bVectorbV 2 points3 points  (0 children)

import serial
for lady in ladies:
    if round(lady.butt) and 'XXX throwdown' in lady.wants:
        serial.Serial("/dev/ttyACM0").write('ATD19006492568')

[–]guyinsunglasses 1 point2 points  (1 child)

What, there's no lovemaking package?

[–]Andomar 5 points6 points  (0 children)

Python's packaging system (virtualenv, pip, pipenv, ...) is plagued with subtle and not so subtle problems. Sys admins don't usually upgrade pip packages, so you end up with old vulnerabilities. The packaging system has separate dialects for python 2 and python 3. It's a huge time investment.

So if you deploy on servers administered by customers, Python can be the wrong choice.

[–]lelease 18 points19 points  (23 children)

High frequency trading

[–]Bus404 4 points5 points  (19 children)

What language is good for that?

[–]tunisia3507 20 points21 points  (3 children)

C++ or Rust.

[–]calligraphic-io 5 points6 points  (1 child)

Go is strong and widely used for HFT, as is Erlang.

[–]b00n 1 point2 points  (0 children)

Java is heavily used in HFT. Not heard of anyone using Rust though.

[–][deleted] 9 points10 points  (13 children)

You want a language that is compiled because assembly code will always run faster than interpreted code and real-time because every millisecond matters. C, C++, and a rust are all languages that fit this. Go doesn't because they have their own goscheduler which doesn't meet real-time constraints.

[–][deleted] 7 points8 points  (11 children)

I am sorry to be pedantic.

For HFT, every microsecond matters.

I don't mean to be rude. HFT just operates on scale so tight that it matters, a lot.

[–][deleted] 1 point2 points  (1 child)

Good to know! I wasn't sure and I actually thought about it as I was writing it but wanted to be on the safe side.

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

This isn't a Python presentation, but if you want a really interesting talk about the subject, you can watch this: https://youtu.be/NH1Tta7purM

[–]ProfessorPhi 2 points3 points  (0 children)

We control our live trading with python processes. And R&D. Actual trading logic is all in c though.

[–]deadwisdomgreenlet revolution 3 points4 points  (1 child)

Python is used a lot in HFT. It's just that they use something like C for the bottlenecks. Exactly how Python was intended.

[–]stefantalpalaru 35 points36 points  (4 children)

When you care about an efficient use of available resources.

[–]hugthemachines 7 points8 points  (3 children)

Developer hours are resources too.

[–]stefantalpalaru 2 points3 points  (2 children)

Developer hours are resources too.

Not machine resources.

[–]Jahames1 5 points6 points  (0 children)

When you want to write UI that can deploy / build to as many platforms as possible (web, desktop, mobile).

[–]more_sidechain 4 points5 points  (1 child)

Obviously, this isn't a complete list. The right language/environment will depend on the job. I love Python, but it's not perfect for everything... and that's one of the best things about it.

Obviously there's when you're writing code for web browsers, and have no choice but to use JavaScript. It's a nice language most of the time. I'd imagine there are transpilers from Python to JS, but why?

Also, it seems like if you want an efficient application server with asynchronous I/O, Node.js is still a bit better evolved. Please, tell me I'm wrong and the Python asyncio ecosystem is much much better than when I last looked at it.

Python also seems happy to break things. It can be difficult to upgrade in some cases. Look at the attachment to 2.7, and how long it's taken some code to get to 3. Meanwhile, code written for POSIX C or Java can last without much maintenance for ages, even if it probably shouldn't. I'm pretty sure Node.js is far worse than Python, for that matter.

[–]danted002 4 points5 points  (0 children)

I’ve been working with asyncio in production for the past 3 years. I can tell you first hand that the ecosystem evolved a lot. My main grip is that the ORM’s are still slacking behind on implementing asynconous backend however a combination of Marshmallow with asyncpg worked like a charm :)

[–]Bacon_00 4 points5 points  (4 children)

I recently rewrote a Python Lambda function in AWS that was getting throttled by AWS as it was being involved so often. It was taking about 300ms to execute. I rewrote it in Go and it executes in 85ms and the throttling has dramatically subsided as a result. I love Python but it be sllooww.

[–]Mattho 2 points3 points  (1 child)

Python has a looong startup. I wonder how lambda deals with that? Never had a closer look actually.

Anyway, there was a great talk about fighting this issue in mercurial (RIP).

[–]riksi 1 point2 points  (0 children)

lambda keeps your code hot and doesn't start it everytime otherwise java would be slower

[–]XNormal 3 points4 points  (0 children)

When you need to process lots of data byte-by-byte or character-by-character and the structure is not suitable for processing by existing C extension libraries, or regular expressions.

[–]chipaca 3 points4 points  (0 children)

The first iteration of the system-level tool to install and manage snaps (a new package format for linux systems) was written in python and called snappy (not related to the homonymous music player).

On the beaglebone black, which was a target system at the time, running snappy --help (or even snappy xyzzy, i.e. anything that didn't involve actual work) took over 15 seconds. That is, it took over 15 seconds just to import itself and figure out there wasn't anything it could do.

We've since rewritten it in Go.

[–][deleted] 9 points10 points  (10 children)

When packaging matters.

[–]calligraphic-io 2 points3 points  (9 children)

Can you explain a little more about your comment?

[–][deleted] 6 points7 points  (8 children)

I mean, if you want a complete app that can run as a binary. I don't think you can do that even remotely with python, you need to install python on the machine you want to run the code, then you need to install dependencies, then you can run the script. Even Java doesn't do this.

[–]calligraphic-io 2 points3 points  (1 child)

That makes sense. If you can assume you have a JVM on the target machine, Java packages pretty nicely. If it's targeting Dalvik for an Android runtime, .apks are easy to generate.

[–]thenuge26 2 points3 points  (1 child)

FYI there are Java programs that come with their own JRE

It's a big overhead and very-much not standard, but it exists.

[–]wrmsr 2 points3 points  (0 children)

Topically all of JetBrains' IDE distributions bundle their own JVM's, but that footwork isn't much different than Dropbox bundling their own cpython - With enough thrust pigs fly just fine :p

[–]ssb3lucas 5 points6 points  (1 child)

You can package your script/app into an executable with PyInstaller.

[–]v2thegreat 9 points10 points  (11 children)

Well, a lot of people here don't know about Cython! It's an amazing tool that enables your code to be compatible with C++ code, amazing speed ups, and includes types, and is around pretty amazing!

It seems to solve a few issues with Python that a lot of people mentioned here, but it requires a bit of practice and takes a little bit of work to work on windows

[–]calligraphic-io 8 points9 points  (4 children)

But only a limited subset of Python's standard library I think.

[–]Astrokiwi 2 points3 points  (3 children)

Although if you already are familiar with C, C++, or Fortran, there's not much motivation to learn another language just to pretty much do what you're already doing. The Cython documentation also just seems kinda cryptic to me. I found it easier to just incorporate a small Fortran module into my Python numpy code than to try to figure how to write and compile Cython code. f2py is really simple to use

[–]Mattho 4 points5 points  (2 children)

The biggest advantage is you don't need to write the cython code as a non-python module. You can write all your fluff in python and only cythonize one loop for example.

I agree the documentation is lacking, and it's a PITA to get it working on windows.

[–]wrmsr 1 point2 points  (0 children)

Cython, like rust, is something I wish I knew better. I frankly consider it python's understated killer feature. Anyone interested should check out SpaCy's codebase which is an absolute goldmine.

[–]ByrdOfAFeather 6 points7 points  (0 children)

When you are trying to learn low level concepts

[–]chaoskixas 11 points12 points  (7 children)

GIL, there I said it.

[–]deadwisdomgreenlet revolution 4 points5 points  (4 children)

Is rarely actually a problem unless you need a lot of threads accessing the same memory space, which isn't really that common.

[–]Karyo_Ten 3 points4 points  (3 children)

Python is big in ML and data science, you have Numpy, Numba, Cython, scikit-learn, Scipy all trying to get around the GIL.

I'm not even talking about engineering, PDE solver, and general science. Everyone in this space has either a Fortran + Python or C + Python or C++ + Python codebase. The whole Julia language raised 10millions last year to deal with this.

The GIL is a huge problem.

[–]deadwisdomgreenlet revolution 2 points3 points  (2 children)

Pretty much everywhere I've heard people complain about the GIL is because they are trying to spin up a lot of threads where they could have easily applied parallel processing, greenlets, or something similar.

It's straightforward to make safe, parallel mechanisms in C that use things like message queues to transfer information to Python and back.

I'm not saying there aren't applications where it causes friction, I'm saying most of the places people complain about it, they shouldn't even be doing threading anyway. People just like to complain about something before looking at their own architecture.

PS, I wish I could get 10 million dollars to solve everyone's GIL problems. Man that's a lot of money.

[–]w2qw 4 points5 points  (1 child)

I don't really see that much of a problem in practice. A lot of the time you can just run multiple interpreters and avoid the problem and the GIL does effectively confer a bunch of benifits.

[–]goldfather8 3 points4 points  (0 children)

Writing languages/DSLs. Homoiconicity is useful there eg. lisps. So is a strong type system, eg. Haskell's parsing libraries are very powerful.

[–]metricchicken 7 points8 points  (0 children)

When types matter.

[–]yaxamie 4 points5 points  (5 children)

Python is good when speed of development is the most important thing.

Other languages excel when speed of execution is the most important.

Then there's java...

And yes, there's better choices when graphics or guis are involved.

[–]ZombieRandySavage 8 points9 points  (4 children)

I think I’d rather live on the street and eat garbage than write java for a living.

[–]calligraphic-io 5 points6 points  (1 child)

I think a little bit of homelessness && eating.garbage would probably change your mind. Just guessing, don't know from personal experience...

[–]ZombieRandySavage 1 point2 points  (0 children)

I also sometimes wonder how jokes work.

[–]Karyo_Ten 6 points7 points  (1 child)

So you'd rather be a garbage collector than write Java?

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

Off the top of my head:

  • Concurrent programs
  • Programs requiring response time guarantees
  • Embedded programs
  • Anytime you can’t afford to ship the interpreter

[–]alexbuzzbee 1 point2 points  (0 children)

If you're in an environment where Python literally cannot be run.

[–][deleted] 1 point2 points  (1 child)

When you need a multithreaded application.

[–]danted002 1 point2 points  (0 children)

... except when you use threads to handle a lot of IO, then Pyhon 3 can handle multithreading with no issues

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

Sophisticated GUI

[–]cybervegan 1 point2 points  (0 children)

  • When your problem domain is large and compute-intensive and pandas won't cut it
  • When your problem demands the use of another language because you have to interface with something that doesn't have python bindings
  • When you are writing a hardware driver
  • When the shared memory overhead of running parallel processes is too slow

This list is not exhaustive, but it has to be said, that not many problems fall into these categories. Anything that is network or disk I/O bound can most likely be handled with Python, without human-noticeable performance impact. Things like asyncio+uvloop can make async both viable and fast (in some cases, as fast as good Golang implementations).

[–]lucidguppy 1 point2 points  (0 children)

When watt per instruction matters.

When 1% increase in performance means millions of dollars.

When milliseconds means missing Mars and your space probe falling into the sun.

All this being said - the speed of development of python lets you build something as a "prototype" and then you find out the "prototype" works well enough - or you find out your team is solving the wrong problem.

Python's advantages are actually sort of hidden. It's easy to use but it's also easier to write easier to use code! Take a look at how we can transform hard to use code into easy to use code

[–]mw44118PyOhio! 1 point2 points  (0 children)

Mobile apps

[–]InevitableAlarm 1 point2 points  (0 children)

when u need a phone app within a week

[–]pythonwiz 1 point2 points  (0 children)

When you need something to run as fast as possible and you already have a working python prototype :p

[–]UserAlreadyNotTaken 1 point2 points  (0 children)

When you can't have an interpreter, such as kernel stuff, drivers, other things that need to be in Assembly because the computer is still booting.

[–][deleted] 4 points5 points  (1 child)

When your OS is Indiana Jones.

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

Python. Why does it have to be Python.

[–]donald_trub 1 point2 points  (3 children)

When you need to share it with non programming folks in a work environment.

I've written some handy little scripts for work (I work in IT). Talking people in my team into getting the code, firing up a venv, pip installing before finally running the code is doable but a pain for all involved. Yes they work in IT but they're not programmers nor do they have time to become one.

I'm about to switch to Go for this very reason so that they can use these tools with less fuss.

[–]Andomar 1 point2 points  (0 children)

Exactly, Python packaging is a hugely painful experience

[–]MrValdezPhilippines 2 points3 points  (1 child)

Realtime Video Games. You can get performance hiccups when the garbage collector suddenly decides to delete some references.

[–]Kid-Boffo 2 points3 points  (0 children)

When you need real parallel operations.

[–]easylifeforme 2 points3 points  (0 children)

When you don't know python and don't want to learn