Dear all,

I'd like to have a class with a method with some implementation internal that
differ if the os is MacOS of anything else.

Context
=======

I'm Fixing #13580 "Parallel map reduce on SearchForest" where I'm writing code
to parallelize some specific computation. In the internal, I need some
synchronizing primitive such as semaphore. However, on MacOS the semaphore are
broken (or at least are not fully POSIX compliant). In particular, on standard
unixes, when two processes are trying to acquire a semaphore whose value is
more than two, they always both succeeded. On MacOS, one of them may fail. As
a consequence, I'm writing a different code form MacOS relying on a Lock and a
shared integer. It may be slower on system where semaphore are implemented in
a lockless way.

Question
========

I'd like to write a *Python* (not C/C++/Cython) code which is supposed to work
fast on any Posix compliant plateform and an alternative implementation on
MacOS. Surprisingly, I can't find any other instance on the whole Sage
library. Do you think it's ok to do that ? Is a code like

    class foo:
        if sys.platform != 'darwin':
            def meth(self):
                print "I'm on a good Posix compliant OS"
        else:
            def meth(self):
                print "I'm using the fallback implementation"

the right way to do it ?

Thanks for any suggestions.

Cheers,

Florent

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to