1.1 --- a/PKG-INFO Thu Jun 19 21:45:03 2008 +0200
1.2 +++ b/PKG-INFO Sun May 04 00:38:20 2008 +0000
1.3 @@ -1,12 +1,12 @@
1.4 Metadata-Version: 1.1
1.5 Name: pprocess
1.6 -Version: 0.3.1
1.7 +Version: 0.3.2
1.8 Author: Paul Boddie
1.9 Author-email: paul at boddie org uk
1.10 Maintainer: Paul Boddie
1.11 Maintainer-email: paul at boddie org uk
1.12 Home-page: http://www.boddie.org.uk/python/pprocess.html
1.13 -Download-url: http://www.boddie.org.uk/python/downloads/pprocess-0.3.1.tar.gz
1.14 +Download-url: http://www.boddie.org.uk/python/downloads/pprocess-0.3.2.tar.gz
1.15 Summary: Elementary parallel programming for Python
1.16 License: LGPL (version 3 or later)
1.17 Description: The pprocess module provides elementary support for parallel
2.1 --- a/README.txt Thu Jun 19 21:45:03 2008 +0200
2.2 +++ b/README.txt Sun May 04 00:38:20 2008 +0000
2.3 @@ -112,6 +112,12 @@
2.4 This software depends on standard library features which are stated as being
2.5 available only on "UNIX"; it has only been tested on a GNU/Linux system.
2.6
2.7 +New in pprocess 0.3.2 (Changes since pprocess 0.3.1)
2.8 +----------------------------------------------------
2.9 +
2.10 + * Added a utility function to detect and return the number of processor
2.11 + cores available.
2.12 +
2.13 New in pprocess 0.3.1 (Changes since pprocess 0.3)
2.14 --------------------------------------------------
2.15
3.1 --- a/pprocess.py Thu Jun 19 21:45:03 2008 +0200
3.2 +++ b/pprocess.py Sun May 04 00:38:20 2008 +0000
3.3 @@ -4,7 +4,7 @@
3.4 A simple parallel processing API for Python, inspired somewhat by the thread
3.5 module, slightly less by pypar, and slightly less still by pypvm.
3.6
3.7 -Copyright (C) 2005, 2006, 2007 Paul Boddie <paul@boddie.org.uk>
3.8 +Copyright (C) 2005, 2006, 2007, 2008 Paul Boddie <paul@boddie.org.uk>
3.9
3.10 This program is free software; you can redistribute it and/or modify it under
3.11 the terms of the GNU Lesser General Public License as published by the Free
3.12 @@ -20,7 +20,7 @@
3.13 with this program. If not, see <http://www.gnu.org/licenses/>.
3.14 """
3.15
3.16 -__version__ = "0.3.1"
3.17 +__version__ = "0.3.2"
3.18
3.19 import os
3.20 import sys
3.21 @@ -32,6 +32,11 @@
3.22 except ImportError:
3.23 import pickle
3.24
3.25 +try:
3.26 + set
3.27 +except NameError:
3.28 + from sets import Set as set
3.29 +
3.30 # Communications.
3.31
3.32 class AcknowledgementError(Exception):
3.33 @@ -523,6 +528,43 @@
3.34
3.35 # Utility functions.
3.36
3.37 +_cpuinfo_fields = "physical id", "core id"
3.38 +
3.39 +def get_number_of_cores():
3.40 +
3.41 + """
3.42 + Return the number of distinct, genuine processor cores. If the platform is
3.43 + not supported by this function, None is returned.
3.44 + """
3.45 +
3.46 + try:
3.47 + f = open("/proc/cpuinfo")
3.48 + try:
3.49 + processors = set()
3.50 + processor = [None, None]
3.51 +
3.52 + for line in f.xreadlines():
3.53 + for i, field in enumerate(_cpuinfo_fields):
3.54 + if line.startswith(field):
3.55 + t = line.split(":")
3.56 + processor[i] = int(t[1].strip())
3.57 + break
3.58 + else:
3.59 + if line.startswith("processor") and processor[0] is not None:
3.60 + processors.add(tuple(processor))
3.61 + processor = [None, None]
3.62 +
3.63 + if processor[0] is not None:
3.64 + processors.add(tuple(processor))
3.65 +
3.66 + return len(processors)
3.67 +
3.68 + finally:
3.69 + f.close()
3.70 +
3.71 + except OSError:
3.72 + return None
3.73 +
3.74 def create():
3.75
3.76 """