question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GSOC 2019: Nuitka all built-ins optimized

See original GitHub issue

Project description: Nuitka has support for many built-ins, e.g. len already, which means dedicated C code, compile time evaluation, type shapes produced (in this case an int), but there are some notable exceptions, e.g. enumerate where we know types too, that are still missing, but definitely can have high performance impact on some loops.

Your task would be to immitate existing built-in codes to achieve a complete support for ultimately all C built-ins. The first step would be to identify which ones are missing (by means of a warning added), then to find out in test runs of the test suites, which ones are warned about, and to resolve as many of those as possible. It is assumed that all should be possible.

Skills: Python and C programming, platform wouldn’t matter

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
kayhayencommented, Feb 3, 2019

As you can see, this is going to give you a nice tour of Nuitka from optimization to code generation, and across various built-ins you may not even know exist, even if you are proficient at Python. I sure didn’t know all of those implemented so far.

1reaction
kayhayencommented, Feb 8, 2019

@bksahu So this is an example of expected effect for generated C code:

Using this test program:

def f():
    x = something()
    return len(x)


-        PyObject *tmp_called_name_2;
-        PyObject *tmp_args_element_name_1;
-        tmp_called_name_2 = LOOKUP_BUILTIN( const_str_plain_len );
-        assert( tmp_called_name_2 != NULL );
+        PyObject *tmp_len_arg_1;
         CHECK_OBJECT( var_x );
-        tmp_args_element_name_1 = var_x;
-        frame_8b78d490904d40bde1d1d570167070ef->m_frame.f_lineno = 4;
-        {
-            PyObject *call_args[] = { tmp_args_element_name_1 };
-            tmp_return_value = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_2, call_args );
-        }
-
+        tmp_len_arg_1 = var_x;
+        tmp_return_value = BUILTIN_LEN( tmp_len_arg_1 );

I got that by disabling the len built-in call optimization, and it shows that instead of calling the built-in name len as a generic function call, we have the dedicated helper BUILTIN_LEN being called.

That is the kind of difference this is about when facing C code. As you can see, this code is not only simpler, but BUILTIN_LEN will be visible to the linker for link time optimization (LTO) once we have that, and can become amazingly faster instead of a relatively generic Python call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

All Python built-ins optimized for Nuitka (sub-org
The proposed project aims to identify all the missing Python. 2.7 to 3.7 (and 3.8 eventually) built-ins in ​Nuitka and to optimize them....
Read more >
2019 Program Python Software Foundation
Nuitka is a Python compiler written in Python. It is a seamless replacement or extension to the Python interpreter and compiles every construct...
Read more >
Nuitka-chat/community - Gitter
I wonder how to get to being able to inline local functions safely, we would have to track the escaping of the value...
Read more >
Nuitka latest version - Awesome Python | LibHunt
This release contains many bug fixes all across the board. There is also new optimization and many organisational improvements. Bug Fixes. Python3.4 ...
Read more >
nuitka Changelog - pyup.io
values, these will be rare, because they all become exceptions. - Optimize calls through variables containing built-in values, unlocking optimization of such ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found