Nuitka Developer Manual

Nuitka Developer Manual

Contents

Milestones

1

Version Numbers

1

Current State

1

Setting up the Development Environment for Nuitka

2

Visual Studio Code

2

Eclipse / PyCharm

2

Commit and Code Hygiene

2

Coding Rules Python

3

Tool to format

3

Identifiers

3

Classes

3

Functions

3

Module/Package Names

4

Context Managers

4

Prefer list contractions over built-ins

4

Coding Rules C

5

The "git flow" model

5

Nuitka "git/github" Workflow

6

API Documentation and Guidelines

7

Use of Standard Python __doc__ Strings

7

Special doxygen Anatomy of __doc__

7

Checking the Source

8

Running the Tests

8

Running all Tests

8

Basic Tests

10

Syntax Tests

11

Program Tests

11

Generated Tests

11

Compile Nuitka with Nuitka

11

Internal/Plugin API

11

Working with the CPython suites

12

Resetting CPython suites

12

Added new CPython suites

12

Design Descriptions

13

Nuitka Logo

13

Choice of the Target Language

13

Use of Scons internally

14

Locating Modules and Packages

16

Hooking for module import process

16

Supporting __class__ of Python3

17

Frame Stack

18

Parameter Parsing

19

Input

19

Keyword dictionary

19

Argument tuple

19

SSA form for Nuitka

19

Loop SSA

21

Python Slots in Optimization

21

Basic Slot Idea

21

Representation in Nuitka

22

The C side

23

Built-in call optimization

24

Code Generation towards C

24

Exceptions

25

Statement Temporary Variables

25

Local Variables Storage

25

Exit Targets

25

Frames

25

Abortive Statements

25

Constant Preparation

26

Language Conversions to make things simpler

26

The assert statement

26

The "comparison chain" expressions

26

The execfile built-in

27

Generator expressions with yield

28

Function Decorators

28

Functions nested arguments

28

In-place Assignments

29

Complex Assignments

29

Unpacking Assignments

29

With Statements

30

For Loops

31

While Loops

32

Exception Handlers

33

Statement try/except with else

34

Class Creation (Python2)

34

Class Creation (Python3)

35

Generator Expressions

36

List Contractions

37

Set Contractions

37

Dictionary Contractions

37

Boolean expressions and and or

38

Simple Calls

38

Complex Calls

38

Assignment Expressions

39

Match Statements

40

Print Statements

40

Reformulations during Optimization

42

Builtin zip for Python2

42

Builtin zip for Python3

42

Builtin map for Python2

43

Builtin min

44

Builtin max

44

Call to dir without arguments

44

Calls to functions with known signatures

44

Nodes that serve special purposes

46

Try statements

46

Releases

47

Side Effects

47

Caught Exception Type/Value References

47

Hard Module Imports

47

Locals Dict Update Statement

48

Optimizing Attribute Lookups into Method Calls for Built-ins types

48

Plan to add "ctypes" support

48

Goals/Allowances to the task

48

Type Inference - The Discussion

49

Applying this to "ctypes"

51

Excursion to Functions

52

Excursion to Loops

53

Excursion to Conditions

54

Excursion to return statements

55

Excursion to yield expressions

55

Mixed Types

55

Back to "ctypes"

56

Now to the interface

56

Discussing with examples

58

Code Generation Impact

58

Initial Implementation

59

Goal 1 (Reached)

59

Goal 2 (Reached)

60

Goal 3

60

Goal 4

61

Limitations for now

62

How to make Features Experimental

63

Command Line

63

In C code

63

In Python

63

When to use it

64

When to remove it

64

Adding dependencies to Nuitka

64

Adding a Run Time Dependency

64

Adding a Development Dependency

65

Idea Bin

65

Prongs of Action

67

Builtin optimization

67

Class Creation Overhead Reduction

68

Memory Usage at Compile Time

68

Coverage Testing

68

Python3 Performance

68

Caching of Python level compilation

68

Updates for this Manual

68

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download