osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to make Python run as fast (or faster) than Julia


On Mon, Mar 5, 2018 at 3:53 PM, Python <python at bladeshadow.org> wrote:
> On Sat, Mar 03, 2018 at 08:18:03AM +1100, Chris Angelico wrote:
>> > Python is often a preferred solution because it is often fantastic for
>> > rapid implementation and maintainability.  The GIL's interference
>> > with threaded code performance has, for me at least, on several
>> > occasions been...  disappointing (perf costs of removing it aside)
>> > because it gets in the way of choosing Python for such solutions.
>> > Jython and IronPython are simply not feasible options for me, for
>> > multiple reasons that have zero to do with their technical
>> > suitability.
>>
>> Have you actually tried it and run into problems,
>
> Yes.  It was years ago and I forget the details, but I even posted
> some sample code here and was told (quite possibly by you) that it was
> the GIL that was eating my lunch.  Someone suggested writing the bits
> I wanted to thread as a C extension, which largely defeated the
> purpose of using Python.  In at least one case I just used C++, and in
> another I just ignored the problem until it went away.

So how about a little Cython?  It has decent GIL control, isn't much
different from Python syntactically, and can be used to create C
extension modules callable from CPython.  It allows you to pretty
freely intermix Python data types and C data types - just be careful
about implicit conversions from one to the other - they can slow
things down.