473,714 Members | 3,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PEP for nondeterminism.

I frequently find myself in a situation where I wish I could say "the
execution order of these two lines just doesn't matter."

Proposed here are two freshly drafted PEP's advocating for the addition
of nondeterminism as a spring board for future automatic parallelism.

The first calls for core language changes, the second calls for a minor
(and likely symbolic) change to list comprehension's semantics to better
support future parallelism.

PEP: XXX
Title: Nondeterminism
Version: $Revision$
Last-Modified: $Date$
Author: Adam DePrince <ad***********@ gmail.com>
Status: Draft
Python-Version: 3.0
Type: Standards
Content-Type: text/plain
Created: 24-Mar-2006
Post-History:
Abstract

Proposed herein is are two new control flow structures that allow
the explicit specification of parallelism by defining the order of
expression evaluation as non-deterministic, thus removing the
requirement of sequential execution.
Background

A number of mechanisms have been proposed in Python that have the
side effect of permitting the automatic discovery of parallelism.
PEP 288 presents the notion of a generator, an object that
inherently lends itself to concurrent operation and possibility
automatic self organization of a pipeline.

Stackless Python in PEP 219/220 presents a mechanism by which a
large number micro threads could be efficiently supported, thus
allowing for a realistic manifestation of a deep generator based
software pipeline.

Additionally, this PEP's sibling, XXX, proposes that the
execution order of list comprehensions be made non-deterministic
to permit future parallel implementations .

DISCUSSION

Two new control flow structures are proposed. While as of yet no
name is proposed, for the sake of brevity we will refer to them as
any and first.

The any structure would call for the execution of all expressions
within the any block in an non-determinate order. The user would
warrant that no side effects exist between the expressions, and
assigned to the variable the any block would be a list
representing the return values of each of the expressions in the
order they appear in the code (but not necessarily in the order of
execution.)

The first structure would execute all enclosed expressions
concurrently, again, the order of execution being
non-deterministic, other than the promise that all would be
started. The return value of the first expression to finish would
be assigned to the variable associated with the first block and
the execution of the other operations terminated.

SPECIFICATION

The use of the word 'any' and 'first' is only a convenience. I do
not yet propose a keyword for these structures.

...
any retval:
1
2+3
my_function_tha t_returns_17()
...

retval would be assigned [1, 5, 17] Only the order of evaluation
is not deterministic.

first retval:
urllib.open( 'mirror1' ).read()
urllib.open( 'mirror2' ).read()
urllib.open( 'mirror3' ).read()
....

retval would contain the data from the fastest mirror, the other
threads would be disposed of.

IMPLEMENTATION
TBD - Incomplete
REFERENCES
TBD
COPYRIGHT

This document has been placed in the public domain.


PEP: XXX
Title: Nondeterministi c List comprehensions
Version: $Revision$
Last-Modified: $Date$
Author: Adam DePrince <ad***********@ gmail.com>
Status: Draft
Python-Version: 3.0
Type: Standards
Content-Type: text/plain
Created: 24-Mar-2006
Post-History:
Abstract

The semantics of the list comprehension offer the future benefit
of multi-threading and parallel execution, assuming that the
programmer treat the order of evaluation as non-deterministic and
avoids the introduction of dependencies and side-effects.

Background

A number of mechanisms have been proposed in Python that have the
side effect of permitting the automatic discovery of parallelism.
PEP 288 presents the notion of a generator, an object that
inherently lends itself to concurrent operation and possibility
of automatic self organization of pipelined, and thus parallel,
operation.

Stackless Python in PEP 219/220 presents a mechanism by which a
large number micro threads could be efficiently supported, thus
allowing for a realistic manifestation of a deep generator based
software pipeline.
DISCUSSION

Generators and generator comprehension are often regarded as
superior to list comprehension due to the reduced footprint of
in-flight data and the future potential of vertical parallelism via
pipelining.

List comprehensions, while having the drawback of requiring the
presence of the entire working set in-flight, places no inherent
restriction on the order of execution. This permits us to
distribute the execution effort horizontally across multiple
micro-threads, with a far higher potential for parallelism than
generators at the expense of requiring the user warrant the
absence of side effects of dependencies between each passing of
the list comprehension loop.

This minor semantic requirement that list comprehension possess
no interdependenci es or side effects permits us to operate on the
list in an arbitrary order, including dispatching the execution
across multiple threads.

SPECIFICATION

We change the semantics of a the list comprehension to
explicitly state that the order of evaluation is
non-deterministic, and that there should exist no dependencies or
side effects. This leaves open the potential for future
parallelization .
PROBLEMS

There are a currently a number of problems. Generators provide an
intuitive and natural partitioning of the problem. The future
partitioning of a list comprehension is a more capricious;
generally, we choose a fixed number of threads to dovetail across,
but little guidance can be gleaned from the use.

The second drawback is the current state of python. With the
global interpreter lock firmly in place, we have no compelling
argument by which to parallelize our list comprehension, even if
they were partitioned. Currently the creation of said
micro-threads and the dovetailing of the workload would actually
increase the execution time in the current 2.4 implementation of
Python. Generators, even with the current lack of real
parallelism to the resulting pipeline, benefit from the drastic
reduction in the amount of in-flight data during their execution.

The third problem is in the near term, this PEP calls for no
implementation change, its only a request that users regard the
execution order as non-deterministic. There is a reasonable change
that this would be ignored.

Lastly, there has been discussion of recasting list comprehension
as generator comprehensions as an easy of normalizing the
semantics of the iterator variable with respect to the callee's
name-space. Such an effort would assign an explicit order of
execution to the list comprehension.
REFERENCES
TBD
COPYRIGHT

This document has been placed in the public domain.


Mar 25 '06 #1
0 1113

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
33976
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
34
2074
by: Spidey | last post by:
What kind of formating can be done with %p in printf
852
28439
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for my general education. Mark
32
2725
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template issue. A noddy mixin layer example should illustrate the issue... class Base { protected: int m_Field;
0
8808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9077
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4729
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3160
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2525
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.