How to install Python package from source on Windows

bartc bc at freeuk.com
Tue May 16 12:09:12 EDT 2017


On 16/05/2017 08:53, Chris Angelico wrote:
> On Tue, May 16, 2017 at 5:14 PM, Christian Gollwitzer <auriocus at gmx.de> wrote:
>> Am 15.05.17 um 23:58 schrieb Chris Angelico:
>>>
>>> On Tue, May 16, 2017 at 7:01 AM, Deborah Swanson
>>> <python at deborahswanson.net> wrote:
>>>>
>>>> But I'm a little more mystified that official Python builds are leaning
>>>> on Visual C++ (and that's what the crutch comment was primarily aimed
>>>> at).
>>>
>>> You seem to be of the opinion that some day, binary executables will
>>> be compiled using pure Python code. Maybe that's true; maybe it's not.
>>
>>
>> More likely would be the option to ship a C compiler with Python written in
>> C. For C++ this is way too big, but a pure C compiler can be as small as
>> 1MB. tcc has a liberal license, supports many platforms and gives reasonable
>> (unoptimized) code. AFAIK Mathworks does that, they ship tcc on Windows so
>> that you can build .mex files without installing additional software, though
>> they recommend to get a decent compiler for performance reasons
>>
>
> To do that, Python would itself have to be compiled with tcc, or else
> all memory de/allocation would have to be funneled through a
> Python-provided API. And that's going to kill performance, I suspect.

I can't test with Python because it's too complicated to compile, 
especially on Windows.

But if I use tcc to compile /my/ byte-code interpreter, and then run the 
interpreter on a computationally intensive benchmark (jpeg decoding), I 
get these results for a given input file:

Tiny C     6.7 seconds
gcc -O3    3.6 seconds

So it is not that terrible. And there are also other, smaller compilers 
which will generate better code than Tiny C. (I don't know why so many 
bundle gcc with their language apps because is not exactly compact.)

(My own [not C] compiler, which has a rubbish code-generator, manages 
4.9 seconds on this test. My own C compiler, with even worse code at the 
minute, still does 5.6 seconds, but is not advanced enough to compile 
CPython.)

Note that Tiny C is poor at code for switch-statements, which are used 
quite a bit in this application, and doesn't handle label pointers. I 
believe that CPython makes use of label pointers with gcc to get an 
extra boost.

-- 
bartc



More information about the Python-list mailing list