Stackless python and multicores?

后端 未结 1 1594
礼貌的吻别
礼貌的吻别 2020-12-24 13:48

So, I\'m toying around with Stackless Python and a question popped up in my head, maybe this is \"assumed\" or \"common\" knowledge, but I couldn\'t find it actually written

相关标签:
1条回答
  • 2020-12-24 14:42

    Stackless python does not make use of any kind of multi-core environment it runs on.
    This is a common misconception about Stackless, as it allows the programmer to take advantage of thread-based programming. For many people these two are closely intertwined, but are, in fact two separate things.

    Internally Stackless uses a round-robin scheduler to schedule every tasklet (micro threads), but no tasklet can be run concurrent with another one. This means that if one tasklet is busy, the others must wait until that tasklet relinquishes control. By default the scheduler will not stop a tasklet and give processor time to another. It is the tasklet's responsibility to schedule itself back in the end of the schedule queue using Stackless.schedule(), or by finishing its calculations.

    all tasklets are thus executed in a sequential manner, even when multiplpe cores are available.

    The reason why Stackless does not have multi-core support is because this makes threads a whole lot easier. And this is just what stackless is all about:

    from the official stackless website

    Stackless Python is an enhanced version of the Python programming language. It allows programmers to reap the benefits of thread-based programming without the performance and complexity problems associated with conventional threads. The microthreads that Stackless adds to Python are a cheap and lightweight convenience which can if used properly, give the following benefits:

    • Improved program structure.
    • More readable code.
    • Increased programmer productivity.

    Here is a link to some more information about multiple cores and stackless.

    0 讨论(0)
提交回复
热议问题