473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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_that_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: Nondeterministic 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 interdependencies 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 1098

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

Similar topics

699
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...
34
by: Spidey | last post by:
What kind of formating can be done with %p in printf
852
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...
32
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...

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.