Current location - Trademark Inquiry Complete Network - Futures platform - Why does artificial intelligence use Python?
Why does artificial intelligence use Python?

This is a misunderstanding. The core algorithm of artificial intelligence is completely dependent on C/C++. Because it is computationally intensive, it requires very fine optimization and interfaces such as GPU and dedicated hardware. These are only possible with C/C++. So in a sense, C/C++ is actually the most important language in the field of artificial intelligence.

Python is the API binding of these libraries. Python is used because of the glue language characteristics of CPython. To develop a cross-language interface from other languages ??to C/C++, Python is the easiest, compared to other languages. The threshold is much lower, especially when using Cython. Many ffi in other languages ??can only import C function entry points, and most complex data structures can only be put together manually using byte arrays. If callback function input is also needed, there is nothing you can do. CPython's C API is bidirectionally integrated, and can directly expose encapsulated Python objects to the outside world. It can also allow users to introduce new features by inheriting these custom objects, and even call Python functions from C code (of course, there are also certain conditions). But this is also an obstacle for JIT interpreters like PyPy.

And Python has always been an important tool for scientific computing and data analysis in history. With a foundation like numpy, because the industries are similar, Python will be the first choice when choosing an API binding language, and at the same time, numpy will be reused. The basic library not only reduces the development workload, but also makes it easier for practitioners to get started.