Skip to content
Getting Digital

Python

Also: python programming, python language

Python is a general-purpose programming language that became the standard interface for driving numerical and machine-learning code written in other languages.

Assessment. Python did not win artificial intelligence by being pleasant to read. It won by being the most convenient way to drive libraries written in C, C++ and CUDA, and by settling on a single array object that every one of those libraries agreed to accept.

Almost none of the computation in a Python machine-learning program happens in Python. Call a matrix multiplication and the interpreter spends a few microseconds arranging arguments before handing control to compiled code, which does the arithmetic over a contiguous block of memory, frequently on a GPU, and returns. The language's celebrated slowness applies to the arranging, not to the arithmetic, and the arranging happens once per operation rather than once per number. That boundary is the entire trick, and it is why the argument about Python being slow keeps missing what the language is being used for. It is not performing the work. It is describing the work to something else, and it is unusually good at that because its C extension interface is old, stable and widely understood, so a library author working in another language can expose a usable surface without adopting Python's runtime for anything that matters.

The other half of the explanation is standardisation. The NumPy array became a shared currency: pandas, SciPy, scikit-learn, the plotting libraries and later the deep-learning frameworks all accept and return the same object, so tools written by strangers who never coordinated compose without conversion layers between them. That is a rarer achievement than it sounds, and the alternatives lost to it for individual reasons rather than one general one. R is superb at statistics and never became the language anyone would also write the serving layer in. MATLAB was licensed per seat, which excluded the students and open-source researchers who went on to write the field's next decade of code. Julia addressed the underlying problem more elegantly and arrived after the ecosystem had already set. The clearest evidence sits in the history of one framework: Torch was respected and written in Lua, the same research lineage rebuilt it with a Python front end as PyTorch, and the audience followed the front end rather than the ideas, which had barely changed.

What to learn, and where the edges are

For a beginner the usual advice is correct, for a slightly different reason than the one usually given. Learn Python first not because the syntax is gentle, although it is, but because it leaves you one import away from nearly every tool you will subsequently need: pandas and Polars for tables, scikit-learn for classical models, PyTorch for neural networks, Matplotlib when a chart is for your own eyes. The gentle syntax earns its reputation mainly by keeping the difficulty inside the problem instead of inside the ceremony. Then learn where the edges are, before an interviewer finds them for you. Loops written in pure Python over large collections are slow enough to matter, and the remedy is to push the loop down into a library call rather than to optimise the loop itself. The global interpreter lock prevents threads from executing Python bytecode simultaneously, which is largely irrelevant to numerical work because the compiled libraries release it while they compute, and recent versions have shipped an experimental build without that lock at all. Packaging remains the least pleasant part of the language by a wide margin, so pick one modern environment manager and use it for everything. None of that changes the recommendation. It means you will know which complaints about Python are real and which are only recited.

In practice

Two ways to total a column of numbers. Write a loop over a pandas DataFrame with iterrows and the interpreter handles every row personally: unpacking it, building a Python object for each value, adding, storing. Call the column's sum method instead and there is a single trip across the boundary, after which compiled code walks a contiguous array with no Python objects involved at any point. The two lines look about equally simple and behave nothing alike as the data grows, which makes this the most useful thing a newcomer can internalise about the language. Your job is to say what should happen to the whole array. Visiting it yourself means you have crossed back over the boundary that made the language fast enough in the first place.

Often confused with

Data Analysis
Python is an instrument for doing analysis, not a synonym for it. Somebody can be fluent in the language and still be unable to say whether the gap between two groups means anything.
Machine Learning
Most machine learning is written in Python, which makes the two easy to merge in the mind. The ideas are mathematical and would survive the language disappearing; only the libraries are Python-specific.

Key takeaways

  • →The computation is not happening in Python: the language describes work to compiled libraries, which is why its own speed seldom decides anything.
  • →A shared array object let independently written libraries compose, and that interoperability beat languages that were technically better but arrived later.
  • →Learn it for the ecosystem rather than the syntax, and learn where the interpreter boundary sits so you stay on the correct side of it.

Related concepts

Courses that teach this

Where this concept sits in the field

Certifications that test this

Vendor exams whose syllabus covers this concept: facts, cost and a preparation path on each page.

FAQ

Why is Python so dominant in AI?
Because it is an excellent front end to code written in other languages, and because everything standardised on one array type early. The heavy arithmetic runs in C, C++ and CUDA; Python assembles it, which is work the interpreter is fast enough for. The rival explanation, that readable syntax won, does not hold up: plenty of readable languages exist and none of them acquired PyTorch. Torch moving off Lua and taking its audience with it is the closest thing the field has to a controlled experiment.
Is Python a good first language?
Yes, with one qualification. If you already know you are heading for front-end web work, JavaScript is the first language for you and Python is a detour. For anything touching data, automation, scientific work or AI, start here. Learning a statically typed language afterwards is a normal and useful second step, and it goes faster once you can already program.
Do I need to learn R as well?
Usually not. R is entrenched in academic statistics, biostatistics and pharmaceutical work, and if you are going there you will need it and it will be worth it. Everywhere else, Python does the same jobs adequately and does the surrounding jobs, the production pipeline and the deployed model, far better. Learning both to a mediocre level is a worse outcome than knowing one of them properly.

Sources

The primary text this definition rests on. Read it before relying on this one.

Last reviewed 26 September 2026 · Getting Digital