Python 上下文中的运行时是什么?它由什么组成? [英] What is runtime in context of Python? What does it consist of?

查看:60
本文介绍了Python 上下文中的运行时是什么?它由什么组成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个问题的上下文中什么是运行时"?(https://stackoverflow.com/questions/3900549/what-is-runtime/3900561)

In context to this question What is "runtime"? (https://stackoverflow.com/questions/3900549/what-is-runtime/3900561)

我试图了解 Python 运行时由什么组成.我的猜测是:

I am trying to understand what would a python runtime be made of. My guess is:

  1. 包含所有运行时变量的 Python 进程.
  2. GIL
  3. 底层解释器代码(CPython 等).

现在,如果这是正确的,我们可以说 python 中的多处理创建了多个运行时并且一个 python 进程是我们可以直接与运行时相关的东西吗?(我认为这是正确的选择)

Now if this is right, can we say that multiprocessing in python creates multiple runtimes and a python process is something we can directly relate to the runtime? (I think this is the right option)

或者,每个 python 线程都有自己的堆栈,与父进程在相同的 GIL 和内存空间上工作,可以被称为具有单独的运行时?

Or, every python thread with its own stack which works on the same GIL and memory space as the parent process can be called as having a separate runtime?

或者,不管有多少线程或进程正在运行,它都会在一个运行时下运行?

Or, doesn't matter how many threads or processes are running, it will all come under a single runtime?

简单的说,Python上下文中runtime的定义是什么?

Simply put, what is the definition of runtime in the context of Python?

PS:我理解线程和进程之间的区别.GIL:我理解这些影响,但我不理解.

PS: I understand the difference between threads and processes. GIL: I understand the impacts but I do not grok it.

推荐答案

您在谈论计算机科学中两个不同(但相似)的概念;多进程和多线程.以下是一些可能有用的问题/答案汇编:

You are talking about two different (yet similar) concepts in computer science; multiprocess, and multithreading. Here is some compilation of questions/answers that might be useful:

多处理是在单个计算机系统中使用两个或多个中央处理器 (CPU).该术语还指系统支持多个处理器的能力或在它们之间分配任务的能力.

Multiprocessing is the use of two or more central processing units (CPUs) within a single computer system.The term also refers to the ability of a system to support more than one processor or the ability to allocate tasks between them.

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆