Does anybody have any experience with parallel python?
Recently I've made Parallel Python for SMP
I would appreciate any comments/suggestions regarding it.
Thank you!
Parallel Python
-
- User
- Beiträge: 3
- Registriert: Mittwoch 3. Januar 2007, 06:28
- Kontaktdaten:
[b][url=http://www.parallelpython.com]Parallel Python[/url][/b]
-
- Python-Forum Veteran
- Beiträge: 16025
- Registriert: Freitag 20. Juni 2003, 16:30
- Kontaktdaten:
Hi parallelpython, welcome in the forum!
Is it your project? There are examples but I don't see any documentation how it works under the hood.
Anyway, testing for type in the isPrime example is not considered good style.
Is it your project? There are examples but I don't see any documentation how it works under the hood.
Anyway, testing for type in the isPrime example is not considered good style.
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Yes ^^Leonidas hat geschrieben:[...]
Anyway, testing for type in the isPrime example is not considered good style.
isinstance(n, int):
Code: Alles auswählen
def isPrime(n):
"""Returns True if n is prime and False otherwise"""
if not isinstance(n, int) or n < 2:
return False
elif n == 2:
return True
max = int(math.ceil(math.sqrt(n)))
i = 2
while i <= max:
if n % i == 0:
return False
i += 1
return True
Code: Alles auswählen
def isPrime(n):
if not isinstance(n, int):
raise TypeError("n is not from data type int or long")
if n < 2:
return False
# etc.
lg
P.S.: Sorry for my very bad english.
-
- User
- Beiträge: 3
- Registriert: Mittwoch 3. Januar 2007, 06:28
- Kontaktdaten:
Hi Leonidas,Leonidas hat geschrieben:Hi parallelpython, welcome in the forum!
Is it your project?
Yes, it is my project.
In short, it creates worker processes which may run on different cpus/cores.Leonidas hat geschrieben: There are examples but I don't see any documentation how it works under the hood.
These processes execute jobs in parallel.
Zuletzt geändert von parallelpython am Donnerstag 4. Januar 2007, 02:12, insgesamt 2-mal geändert.
[b][url=http://www.parallelpython.com]Parallel Python[/url][/b]
-
- User
- Beiträge: 3
- Registriert: Mittwoch 3. Januar 2007, 06:28
- Kontaktdaten:
Thank you for the feedback!sape hat geschrieben: Much better:BTW: The name of the function is not conform with the PEP8 Style Guide. ``is_prime`` ist better as ``isPrime``Code: Alles auswählen
def isPrime(n): if not isinstance(n, int): raise TypeError("n is not from data type int or long")
I've changed the examples section.
I guess isprime will be even better here (analogous to isinstance)
[b][url=http://www.parallelpython.com]Parallel Python[/url][/b]