[PEP] matching and mismatching

Luke Kenneth Casson Leighton luke.leighton at aspextechnology.com
Thu May 2 13:01:59 EDT 2002


this is an initial proposal idea which i would like to bounce around
with people, to find out if it's a good idea or even in fact if
something
like it has already been added or considered.

the idea: a function/operator similar to map and reduce _or_ a keyword
similar to "in", such that:

for x in ([1,3,2,5,9] matching lambda x:x > 2):
	print x
will output:
3
5
9

or the equivalent to like map/reduce:

print matching([1,2,3], lambda x:x > 2)
will output:
[3]

now, the justification for this, instead of having this:

for x in [1,3,2,5,9]:
	if x > 2:
		print x

is for parallelisation reasons.

the for-loop-plus-if-statement cannot be expected to be
parallelised [in a massively parallel architecture] because
the code-flow is _expected_ to be sequential.

a matching (and its corresponding mismatching) operator/function
_could_, like map, be parallelised, and optimised on parallel
hardware / co-processor support.

what do people think?

luke.

-- 
This email and any files transmitted with it, including replies and
forwarded copies subsequently transmitted from Aspex Technology
Limited, are confidential and solely for the use of the intended
recipient.  Any opinions expressed in this email are those of the
individual and not necessarily those of Aspex Technology Limited.  If
you are not the intended recipient, be advised that you have received
this email in error and that any use is strictly prohibited.  If you
have received this email in error, please notify us immediately by
e-mail and delete the original message without keeping any copies.

Aspex Technology Limited is registered in England and Wales No.3469577.
The registered office for Aspex Technology Limited is
York House, Cottingley Business Park, Bradford, BD16 1PF.





More information about the Python-list mailing list