Debugging in Python 3.6: Better, Faster, Stronger

Size: px
Start display at page:

Download "Debugging in Python 3.6: Better, Faster, Stronger"

Transcription

1 Debugging in Python 3.6: Better, Faster, Stronger Elizaveta Shashkova JetBrains EuroPython 2017

2 Bio Software developer of PyCharm IDE at JetBrains Debugger Saint Petersburg, Russia 2

3 Debugging Adding print statements Logging 3

4 Debugging Adding print statements Logging Special tools: debuggers 4

5 Debugger s Performance Debuggers are 30 times slower Run Debug 5

6 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 6

7 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 7

8 Tracing Function sys.settrace(tracefunc) - set system tracing function def tracefunc(frame, event, arg): print(frame.f_lineno, event) return tracefunc sys.settrace(tracefunc) 8

9 Tracing Function def foo(): friends = ["Bob", "Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 9

10 Tracing Function def foo(): friends = ["Bob", "Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 1 call 10

11 Tracing Function def foo(): friends = ["Bob", Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 1 call 2 line 11

12 Tracing Function def foo(): friends = ["Bob", "Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 1 call 2 line 3 line 4 line Hi Bob! 12

13 Tracing Function def foo(): friends = ["Bob", "Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 1 call 2 line 3 line 4 line Hi Bob! 3 line 4 line Hi Tom! 13

14 Tracing Function def foo(): friends = ["Bob", "Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 1 call 2 line 3 line 4 line Hi Bob! 3 line 4 line Hi Tom! 5 line 5 return 14

15 Build Python Debugger Breakpoints Stepping 15

16 Tracing Debugger Suspend program if breakpoint s line equals frame.f_lineno Handle events for stepping 16

17 Performance def foo(): friends = ["Bob", "Tom"] for f in friends: print("hi %s! % f) return len(friends) sys.settrace(tracefunc) foo() 1 call 2 line 3 line 4 line Hi Bob! 3 line 4 line Hi Tom! 5 line 5 return 17

18 Example def calculate(): sum = 0 for i in range(10 ** 7): sum += i return sum

19 Example def calculate(): sum = 0 for i in range(10 ** 7): sum += i return sum def tracefunc(frame, event, arg): return tracefunc 19

20 Performance Run 0,80 sec Tracing 6,85 sec Breakpoints 19,81 sec 20

21 Performance Run 0,80 sec Tracing 6,85 sec Breakpoints 19,81 sec 21

22 Performance Run 0,80 sec Tracing 6,85 sec Breakpoints 19,81 sec 22

23 Performance Run 0,80 sec Tracing 6,85 sec Breakpoints 19,81 sec ~ 25 times slower! 23

24 Problem Tracing call on every line 24

25 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 25

26 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 26

27 Python

28 Python 3.6 New frame evaluation API PEP

29 PEP 523 Handle evaluation of frames Add a new field to code objects 29

30 Frame Evaluation def frame_eval(frame, exc): func_name = frame.f_code.co_name line_number = frame.f_lineno print(line_number, func_name) return _PyEval_EvalFrameDefault(frame, exc)

31 Frame Evaluation def frame_eval(frame, exc): func_name = frame.f_code.co_name line_number = frame.f_lineno print(line_number, func_name) return _PyEval_EvalFrameDefault(frame, exc) f 31

32 Frame Evaluation def frame_eval(frame, exc): func_name = frame.f_code.co_name line_number = frame.f_lineno print(line_number, func_name) return _PyEval_EvalFrameDefault(frame, exc) f 32

33 Frame Evaluation def frame_eval(frame, exc): func_name = frame.f_code.co_name line_number = frame.f_lineno print(line_number, func_name) return _PyEval_EvalFrameDefault(frame, exc) f 33

34 Frame Evaluation def frame_eval(frame, exc): func_name = frame.f_code.co_name line_number = frame.f_lineno print(line_number, func_name) return _PyEval_EvalFrameDefault(frame, exc) f

35 Frame Evaluation def frame_eval(frame, exc): func_name = frame.f_code.co_name line_number = frame.f_lineno print(line_number, func_name) return _PyEval_EvalFrameDefault(frame, exc) def set_frame_eval(): state = PyThreadState_Get() state.interp.eval_frame = frame_eval 35

36 Example 1 2 def first(): second() def second(): third() def third(): pass set_frame_eval() first() 36

37 Example def first(): second() def second(): third() def third(): pass set_frame_eval() first() 1 first 4 second 7 third 37

38 Custom Frame Evaluation It works! Executed while entering a frame Access to frame and code object 38

39 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 39

40 Problem Tracing call on every line 40

41 Problem Tracing call on every line Remove the tracing function! 41

42 Replace tracing function with frame evaluation function 42

43 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 43

44 Build Python Debugger Breakpoints Stepping 44

45 Breakpoints Access to the whole code object 45

46 Breakpoints Access to the whole code object Insert breakpoint s code into frame s code 46

47 Breakpoints def maximum(a, b): if a > b: return a else: return b

48 Breakpoints def maximum(a, b): if a > b: return a # breakpoint else: return b

49 Breakpoints def maximum(a, b): if a > b: return a # breakpoint else: return b 6 7 breakpoint()

50 Breakpoints def maximum(a, b): if a > b: breakpoint() return a # breakpoint else: return b

51 Python Bytecode def maximum(a, b): if a > b: return a else: return b import dis dis.dis(maximum) 9 51

52 Python Bytecode def maximum(a, b): if a > b: return a else: return b import dis dis.dis(maximum) 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 52

53 Python Bytecode def maximum(a, b): if a > b: return a else: return b import dis dis.dis(maximum) 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 53

54 Python Bytecode def maximum(a, b): if a > b: return a else: return b import dis dis.dis(maximum) 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE f 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 54

55 Python Bytecode def maximum(a, b): if a > b: return a else: return b import dis dis.dis(maximum) 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 55

56 Python Bytecode def maximum(a, b): if a > b: return a else: return b import dis dis.dis(maximum) 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 56

57 Python Bytecode 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 57

58 Python Bytecode 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 58

59 Python Bytecode 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 59

60 Python Bytecode 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 60

61 Bytecode Modification 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) breakpoint() 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b) 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 61

62 Bytecode Modification Insert breakpoint s code Update arguments and offsets 62

63 Bytecode Modification Insert breakpoint s code Update arguments and offsets 200 lines in Python 63

64 Bytecode Modification 2 0 LOAD_FAST 0 (a) 2 LOAD_FAST 1 (b) 4 COMPARE_OP 4 (>) 6 POP_JUMP_IF_FALSE LOAD_FAST 0 (a) breakpoint() 10 RETURN_VALUE 5 >> 12 LOAD_FAST 1 (b)?! 14 RETURN_VALUE 16 LOAD_CONST 0 (None) 18 RETURN_VALUE 64

65 Breakpoint Bytecode def _stop_at_break(): # a lot of code here def breakpoint(): _stop_at_break() 0 LOAD_GLOBAL 0 2 CALL_FUNCTION 0 4 POP_TOP 6 LOAD_CONST 0 8 RETURN_VALUE 65

66 Build Python Debugger Breakpoints Stepping 66

67 Stepping Inserting temporary breakpoint on every line Use old tracing function 67

68 Frame evaluation debugger is ready! 68

69 Example def calculate(): sum = 0 for i in range(10 ** 7): sum += i return sum

70 Example 1 Run 0,80 sec Tracing 19,81 sec Frame evaluation 70

71 Example 1 Run 0,80 sec Tracing 19,81 sec Frame evaluation 0,81 sec 71

72 Example def foo(): pass def calculate(): sum = 0 for i in range(10 ** 7): foo() sum += i return sum 72

73 Example 2 Run 1,73 sec Tracing 43,58 sec Frame evaluation 37,41 sec 73

74 PEP 523 Handle evaluation of frames Add a new field to code objects 74

75 PEP 523 Expand PyCodeObject struct co_extra - scratch space for the code object Mark frames without breakpoints 75

76 Mark Frames def frame_eval(frame, exc): flag = _PyCode_GetExtra(frame.f_code, index) if flag == NO_BREAKS_IN_FRAME: return _PyEval_EvalFrameDefault(frame, exc) # check for breakpoints

77 Example 2 Run 1,73 sec Tracing 43,58 sec Frame evaluation 1,91 sec 77

78 PEP 523 Handle evaluation of frames Add a new field to code objects 78

79 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 79

80 Contents Tracing debugger Python 3.6 Frame evaluation debugger Results 80

81 Real Life Example 81

82 Real Life Example Included into PyCharm Works in production 82

83 PyCharm Tracing w/o Cython 11,59 sec Tracing with Cython 5,66 sec Frame evaluation 0,28 sec 83

84 Frame evaluation rocks! 84

85 Disadvantages More complicated Only with CPython Only with Python

86 Frame Evaluation Let s move to Python 3.6! 86

87 Frame Evaluation Let s move to Python 3.6! Let s find another use cases! 87

88 Use cases def maximum(a, b): if a > b: return a # breakpoint else: return b 6 7 breakpoint()

89 PEP 523 Pyjion project JIT for Python 89

90 Frame Evaluation Let s move to Python 3.6! Let s find another use cases! 90

91 Links Prototype: frame-eval PyCharm Community Edition source code bytesinsert on PyPi 91

92 Questions? Prototype: frame-eval PyCharm Community Edition source code bytesinsert on 92

All-Singing All-Dancing Python Bytecode Larry Hastings EuroPython 2013 July 2, 2013

All-Singing All-Dancing Python Bytecode Larry Hastings EuroPython 2013 July 2, 2013 All-Singing All-Dancing Python Bytecode Larry Hastings larry@hastings.org EuroPython 2013 July 2, 2013 Introduction Intermediate CPython 3.3.0 100% roughly applicable elsewhere What Is Bytecode? Opcodes

More information

bytecode Documentation

bytecode Documentation bytecode Documentation Release 0.5 Victor Stinner January 09, 2017 Contents 1 Table Of Contents 3 1.1 Bytecode Usage............................................. 3 1.1.1 Installation...........................................

More information

Computer Science 200b Exam 2 April 14, 2016

Computer Science 200b Exam 2 April 14, 2016 YOUR NAME PLEASE: NETID: Computer Science 200b Exam 2 April 14, 2016 Enter your netid at the bottom of each page. Closed book and closed notes. No electronic devices. Show ALL work you want graded on the

More information

Implementing Python in Haskell, twice. Bernie Pope Melbourne Haskell Users Group 24th April 2014

Implementing Python in Haskell, twice. Bernie Pope Melbourne Haskell Users Group 24th April 2014 Implementing Python in Haskell, twice. Bernie Pope Melbourne Haskell Users Group 24th April 2014 Overview How it all started language-python berp blip What s the point and where will it end? How it all

More information

Functions #5. Serdar ARITAN. Department of Computer Graphics Hacettepe University, Ankara, Turkey

Functions #5. Serdar ARITAN. Department of Computer Graphics Hacettepe University, Ankara, Turkey #5 Serdar ARITAN Department of Computer Graphics Hacettepe University, Ankara, Turkey 1 I have never considered Python to be heavily influenced by functional languages, no matter what people say or think.

More information

Slightly Advanced Python:

Slightly Advanced Python: Slightly Advanced Python: some well-documented internals http://www.aleax.it/ut_pyadv.pdf 2008 Google -- aleax@google.com Audience level for this talk Shu ("Retain") Ha ("Detach") Ri ("Transcend") 2 This

More information

Armin how Python was shaped by leaky internals

Armin how Python was shaped by leaky internals Armin Ronacher @mitsuhiko how Python was shaped by leaky internals Armin Ronacher @mitsuhiko Flask / Sentry / Lektor http://lucumr.pocoo.org/ The Leaky Interpreter Python is an insanely complex language

More information

HotPy (2) Binary Compatible High Performance VM for Python. Mark Shannon

HotPy (2) Binary Compatible High Performance VM for Python. Mark Shannon HotPy (2) Binary Compatible High Performance VM for Python Mark Shannon Who am I? Mark Shannon PhD thesis on building VMs for dynamic languages During my PhD I developed: GVMT. A virtual machine tool kit

More information

Embracing the Global Interpreter Lock (GIL)

Embracing the Global Interpreter Lock (GIL) Embracing the Global Interpreter Lock (GIL) David Beazley http://www.dabeaz.com October 6, 2011 PyCodeConf 2011, Miami 1 Let's Love the GIL! After blowing up the GIL at PyCon'2010, I thought it needed

More information

Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode

Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode Bugloo: A Source Level Debugger for Scheme Programs Compiled into JVM Bytecode Damien Ciabrini Manuel Serrano firstname.lastname@sophia.inria.fr INRIA Sophia Antipolis 2004 route des Lucioles - BP 93 F-06902

More information

Design and Implementation of an Embedded Python Run-Time System

Design and Implementation of an Embedded Python Run-Time System Design and Implementation of an Embedded Python RunTime System Thomas W. Barr, Rebecca Smith, Scott Rixner Rice University, Department of Computer Science USENIX Annual Technical Conference, June 2012!1

More information

Normal Order (Lazy) Evaluation SICP. Applicative Order vs. Normal (Lazy) Order. Applicative vs. Normal? How can we implement lazy evaluation?

Normal Order (Lazy) Evaluation SICP. Applicative Order vs. Normal (Lazy) Order. Applicative vs. Normal? How can we implement lazy evaluation? Normal Order (Lazy) Evaluation Alternative models for computation: Normal (Lazy) Order Evaluation Memoization Streams Applicative Order: evaluate all arguments, then apply operator Normal Order: pass unevaluated

More information

The Effects of Unrolling and Inlining on Python Bytecode Optimizations

The Effects of Unrolling and Inlining on Python Bytecode Optimizations The Effects of Unrolling and Inlining on Python Bytecode Optimizations Yosi Ben Asher, Nadav Rotem Haifa University 15/6/09 @ The Python Programming Language Very popular dynamic programming language combining

More information

Debugging with PyCharm ~0~ What does it mean to debug a program?

Debugging with PyCharm ~0~ What does it mean to debug a program? Debugging with PyCharm ~0~ 1 What does it mean to debug a program? 2 To debug simply means to locate and remove program bugs, errors or abnormalities. It could be a period you put in the wrong spot or

More information

Introduction to Problem Solving and Programming in Python.

Introduction to Problem Solving and Programming in Python. Introduction to Problem Solving and Programming in Python http://cis-linux1.temple.edu/~tuf80213/courses/temple/cis1051/ Overview Types of errors Testing methods Debugging in Python 2 Errors An error in

More information

ENGR 102 Engineering Lab I - Computation

ENGR 102 Engineering Lab I - Computation ENGR 102 Engineering Lab I - Computation Learning Objectives by Week 1 ENGR 102 Engineering Lab I Computation 2 Credits 2. Introduction to the design and development of computer applications for engineers;

More information

UNIT IV -MACROPROCESSOR

UNIT IV -MACROPROCESSOR CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT IV -MACROPROCESSOR 1. Define macro. A macro represents a group of statements in a source language, for performing some function macro can be defined

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

CS 270 Systems Programming. Debugging Tools. CS 270: Systems Programming. Instructor: Raphael Finkel

CS 270 Systems Programming. Debugging Tools. CS 270: Systems Programming. Instructor: Raphael Finkel Debugging Tools CS 270: Systems Programming Instructor: Raphael Finkel Gdb: The Gnu debugger It runs on most computers and operating systems. It allows you to examine a running executable program. It does

More information

TRACE32 as GDB Back-End

TRACE32 as GDB Back-End TRACE32 as GDB Back-End TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents... GDB Support... TRACE32 as GDB Back-End... 1 Basic Concepts... 2 Introduction 2 Operating of the API Requests

More information

tolerance Documentation

tolerance Documentation tolerance Documentation Release Alisue Apr 1, 217 Contents 1 tolerance 1 1.1 Features.................................................. 1 1.2 Installation................................................

More information

Execution order. main()

Execution order. main() Functions Execution order When you load and run a Python module (file), the statements and definitions in the file are executed in the order in which they occur Executing a def defines a function, it doesn

More information

Hacettepe University Computer Engineering Department. Programming in. BBM103 Introduction to Programming Lab 1 Week 4. Fall 2018

Hacettepe University Computer Engineering Department. Programming in. BBM103 Introduction to Programming Lab 1 Week 4. Fall 2018 Hacettepe University Computer Engineering Department Programming in BBM103 Introduction to Programming Lab 1 Week 4 Fall 2018 Install PyCharm Download Link : https://www.jetbrains.com/pycharm-edu/download/#section=windows

More information

CS61A Notes Week 13: Interpreters

CS61A Notes Week 13: Interpreters CS61A Notes Week 13: Interpreters Read-Eval Loop Unlike Python, the result of evaluating an expression is not automatically printed. Instead, Logo complains if the value of any top-level expression is

More information

Comp 151. Control structures.

Comp 151. Control structures. Comp 151 Control structures. admin quiz this week believe it or not only 2 weeks from exam. one a week each week after that. idle debugger Debugger: program that will let you look at the program as it

More information

Debugging & Errors Why you were up till 2AM

Debugging & Errors Why you were up till 2AM Debugging & Errors Why you were up till 2AM Dan Fleck Fall 2008 Coming up: Running programs from the command line Running programs from the command line In windows just double-click on the sliders.py file

More information

CS2: Debugging in Java

CS2: Debugging in Java CS2: Debugging in Java 1. General Advice Jon Cook (LFCS) April 2003 Debugging is not always easy. Some bugs can take a long time to find. Debugging concurrent code can be particularly difficult and time

More information

funcsigs Documentation

funcsigs Documentation funcsigs Documentation Release 0.4 Aaron Iles December 20, 2013 Contents i ii CHAPTER 1 The Funcsigs Package funcsigs is a backport of the PEP 362 function signature features from Python 3.3 s inspect

More information

CS164 First Midterm Exam Fall 2014

CS164 First Midterm Exam Fall 2014 CS164 First Midterm Exam Fall 2014 October 28 th, 2014 Please read all instructions (including these) carefully. This is a closed-book exam. You are allowed a one-page, one-sided handwritten cheat sheet.

More information

ArcPy Tips & Tricks. Clinton Dow Geoprocessing Product Esri

ArcPy Tips & Tricks. Clinton Dow Geoprocessing Product Esri ArcPy Tips & Tricks Clinton Dow Geoprocessing Product Engineer @ Esri Tip #1 ArcPy in an IDE GIS from the comfort of your development environment Recommended IDEs - PyCharm - Python Tools for Visual Studio

More information

Notices. Test rules. Page 1 of 8. CS 1112 Spring 2018 Test 2

Notices. Test rules. Page 1 of 8. CS 1112 Spring 2018 Test 2 Page 1 of 8 Name: Email id: Notices Based on your past educational achievements, I expect you to do well on this test. Answer the questions in any order that you want. Hand in both parts of the test. Test

More information

Programming in the Real World. Dr. Baldassano Yu s Elite Education

Programming in the Real World. Dr. Baldassano Yu s Elite Education Programming in the Real World Dr. Baldassano chrisb@princeton.edu Yu s Elite Education Our programs are getting bigger! Our game was already over 100 lines long - most programs are worked on by teams of

More information

Optimizations which made Python 3.6 faster than Python 3.5

Optimizations which made Python 3.6 faster than Python 3.5 Optimizations which made Python 3.6 faster than Python 3.5 Pycon US 2017, Portland, OR Victor Stinner vstinner@redhat.com Agenda (1) Benchmarks (2) Benchmarks results (3) Python 3.5 optimizations (4) Python

More information

Debugging of CPython processes with gdb

Debugging of CPython processes with gdb Debugging of CPython processes with gdb KharkivPy January 28th, 2017 by Roman Podoliaka, Development Manager at Mirantis twitter: @rpodoliaka blog: http://podoliaka.org slides: http://podoliaka.org/talks/

More information

ALD Assembly Language Debugger Copyright (C) Patrick Alken

ALD Assembly Language Debugger Copyright (C) Patrick Alken ALD Assembly Language Debugger 0.1.7 Copyright (C) 2000-2004 Patrick Alken To run type ald help Commands may be abbreviated. If a blank command is entered, the last command is repeated. Type `help '

More information

Understanding the Program Run

Understanding the Program Run 0/45 Understanding the Program Run Andreas Zeller Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken Isolating Failure Causes 1/45 So far, we have seen how to isolate causes in the environment

More information

High Performance Python Micha Gorelick and Ian Ozsvald

High Performance Python Micha Gorelick and Ian Ozsvald High Performance Python Micha Gorelick and Ian Ozsvald Beijing Cambridge Farnham Koln Sebastopol Tokyo O'REILLY 0 Table of Contents Preface ix 1. Understanding Performant Python 1 The Fundamental Computer

More information

Dipartimento di Informatica e Scienze dell Informazione

Dipartimento di Informatica e Scienze dell Informazione Dipartimento di Informatica e Scienze dell Informazione High performance implementation of Python for CLI/.NET with JIT compiler generation for dynamic languages. by Antonio Cuni Theses Series DISI-TH-2010-05

More information

Different Species of Python

Different Species of Python Different Species of Python Presented by David Malcolm FUDcon 2011 Tempe Licensed under the Creative Commons Attribution-ShareAlike license: http://creativecommons.org/licenses/by-sa/3.0/

More information

Short Answer Questions (40 points)

Short Answer Questions (40 points) CS 1112 Fall 2017 Test 2 Page 1 of 6 Short Answer Questions (40 points) 1. TRUE FALSE You have very legibly printed your name and email id below. Name = EMAILD = 2. TRUE FALSE On my honor, I pledge that

More information

EE 355 Lab 3 - Algorithms & Control Structures

EE 355 Lab 3 - Algorithms & Control Structures 1 Introduction In this lab you will gain experience writing C/C++ programs that utilize loops and conditional structures. This assignment should be performed INDIVIDUALLY. This is a peer evaluated lab

More information

Course Structure of Python Training: UNIT - 1: COMPUTER FUNDAMENTALS. Computer Fundamentals. Installation of Development Tools:

Course Structure of Python Training: UNIT - 1: COMPUTER FUNDAMENTALS. Computer Fundamentals. Installation of Development Tools: Course Structure of Python Training: UNIT - 1: COMPUTER FUNDAMENTALS Computer Fundamentals o What is a Computer? o Computation vs calculation Microprocessors and Memory Concepts o Discussion on register,

More information

Bachelor Thesis in Computer Science

Bachelor Thesis in Computer Science Eberhard Karls Universität Tübingen Mathematisch-Naturwissenschaftliche Fakultät Wilhelm-Schickard-Institut für Informatik Bachelor Thesis in Computer Science Development of a Data Provenance Analysis

More information

CPython cannot into threads

CPython cannot into threads GIL CPython cannot into threads 1992 PyPy Jython CPython IronPython Brython PyPy Jython CPython IronPython Brython PyPy Jython CPython IronPython Brython CPython cannot into threads CPython cannot into

More information

CS1 Lecture 4 Jan. 23, 2019

CS1 Lecture 4 Jan. 23, 2019 CS1 Lecture 4 Jan. 23, 2019 First graded discussion sections this week yesterday/today 10 DS assignments worth 2 points each everyone gets one free 2-pointer. I.e. your lowest DS grade will be replaced

More information

All written answers are limited to their question boxes. Make sure all answers are easily legible.

All written answers are limited to their question boxes. Make sure all answers are easily legible. All written answers are limited to their question boxes. Make sure all answers are easily legible. 1. (1 point) Print your name and email id. 2. (2 points) What makes functions so important? Ability to

More information

Multi-Level Debugging for Cython

Multi-Level Debugging for Cython Multi-Level Debugging for Cython Mark Florisson University of Twente P.O. Box 217, 7500AE Enschede The Netherlands markflorisson88@gmail.com ABSTRACT Programs may be written in multiple languages and may

More information

Exercise Session 6 Computer Architecture and Systems Programming

Exercise Session 6 Computer Architecture and Systems Programming Systems Group Department of Computer Science ETH Zürich Exercise Session 6 Computer Architecture and Systems Programming Herbstsemester 2016 Agenda GDB Outlook on assignment 6 GDB The GNU Debugger 3 Debugging..

More information

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni Using the Debugger Michael Jantz Dr. Prasad Kulkarni 1 Debugger What is it a powerful tool that supports examination of your program during execution. Idea behind debugging programs. Creates additional

More information

Implementation of F# language support in JetBrains Rider IDE

Implementation of F# language support in JetBrains Rider IDE SAINT-PETERSBURG STATE UNIVERSITY Software Engineering Evgeniy Auduchinok Implementation of F# language support in JetBrains Rider IDE Graduation Thesis Scientific supervisor: Senior lecturer Iakov Kirilenko

More information

A control expression must evaluate to a value that can be interpreted as true or false.

A control expression must evaluate to a value that can be interpreted as true or false. Control Statements Control Expressions A control expression must evaluate to a value that can be interpreted as true or false. How a control statement behaves depends on the value of its control expression.

More information

Debugging Hung Python Processes With GDB. Brian Bouterse Principle Software Engineer, Red Hat. Pulp (pulpproject.org) Feb 5, 2017

Debugging Hung Python Processes With GDB. Brian Bouterse Principle Software Engineer, Red Hat. Pulp (pulpproject.org) Feb 5, 2017 Debugging Hung Python Processes With GDB Brian Bouterse Principle Software Engineer, Red Hat. Pulp (pulpproject.org) Feb 5, 2017 2 Why use GDB to debug Python software? 3 Why use GDB to debug Python software?

More information

Bug Hunting For Dummies

Bug Hunting For Dummies Bug Hunting For Dummies Antonio Cuni EuroPython 2013 July 2, 2013 antocuni (EuroPython 2013) Bug Hunting July 2, 2013 1 / 33 About me PyPy core dev pdb++, fancycompleter,... Consultant, trainer http://antocuni.eu

More information

C5500 Compiler Build Options One Use Case

C5500 Compiler Build Options One Use Case C5500 Compiler Build Options One Use Case May 2008 Page 1 Page 1 TI Internal Use Only Overview These slides are the collective wisdom on C5500 Compiler Build options from a highly experienced development

More information

Project 3 Due October 21, 2015, 11:59:59pm

Project 3 Due October 21, 2015, 11:59:59pm Project 3 Due October 21, 2015, 11:59:59pm 1 Introduction In this project, you will implement RubeVM, a virtual machine for a simple bytecode language. Later in the semester, you will compile Rube (a simplified

More information

Thermo-Calc Property Model Framework Documentation

Thermo-Calc Property Model Framework Documentation Thermo-Calc Property Model Framework Documentation Release 2017b Thermo-Calc Software AB Aug 23, 2017 CONTENTS 1 Introduction 1 1.1 Thermo-Calc Custom Property Models.................................

More information

Agile development. Agile development work cycle. Reacting to bugs

Agile development. Agile development work cycle. Reacting to bugs Agile development Agile development work cycle Repeat until all features are implemented: 1. Write a test that defines your next feature 2. Write the simplest version of code that makes your test 3. Run

More information

Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs

Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs Slide Set 2 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

psd: A Scheme Debugger An Example

psd: A Scheme Debugger An Example psd: A Scheme Debugger An Example Peter Møller Neergaard When learning a new programming language, your first step is often to write a hello world -program. The next step you want to take is to figure

More information

Repetition and Loop Statements Chapter 5

Repetition and Loop Statements Chapter 5 Repetition and Loop Statements Chapter 5 1 Chapter Objectives To understand why repetition is an important control structure in programming To learn about loop control variables and the three steps needed

More information

Reviewing gcc, make, gdb, and Linux Editors 1

Reviewing gcc, make, gdb, and Linux Editors 1 Reviewing gcc, make, gdb, and Linux Editors 1 Colin Gordon csgordon@cs.washington.edu University of Washington CSE333 Section 1, 3/31/11 1 Lots of material borrowed from 351/303 slides Colin Gordon (University

More information

CS 11 C track: lecture 6

CS 11 C track: lecture 6 CS 11 C track: lecture 6 Last week: pointer arithmetic This week: The gdb program struct typedef linked lists gdb for debugging (1) gdb: the Gnu DeBugger http://courses.cms.caltech.edu/cs11/material /c/mike/misc/gdb.html

More information

peval Documentation Release Bogdan Opanchuk

peval Documentation Release Bogdan Opanchuk peval Documentation Release 0.1.0 Bogdan Opanchuk January 29, 2016 Contents 1 Introduction 1 2 Implementation details 3 3 Restrictions on functions 5 4 API reference 7 4.1 Core functions..............................................

More information

Using gdb to find the point of failure

Using gdb to find the point of failure gdb gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and g++, this is accomplished using the -g option,

More information

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters.

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters. CS 61A Spring 2019 Guerrilla Section 5: April 20, 2019 1 Interpreters 1.1 Determine the number of calls to scheme eval and the number of calls to scheme apply for the following expressions. > (+ 1 2) 3

More information

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Python I. Some material adapted from Upenn cmpe391 slides and other sources Python I Some material adapted from Upenn cmpe391 slides and other sources Overview Names & Assignment Data types Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics

More information

Simplifying Asynchronous Code with

Simplifying Asynchronous Code with Simplifying Asynchronous Code with Scala Async JASON ZAUGG PHILIPP HALLER The Problem Asynchronous code ubiquitous Intrinsic to programming models like actors Required for performance and scalability See

More information

COL728 Minor2 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20

COL728 Minor2 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20 COL728 Minor2 Exam Compiler Design Sem II, 2017-18 Answer all 5 questions Max. Marks: 20 1. Short questions a. Give an example of a program that is not a legal program if we assume static scoping, but

More information

Final Exam Version A

Final Exam Version A CS112 Spring 2014 Dr. Kinga Dobolyi Final Exam Version A Do not open this exam until you are told. Read these instructions: 1. This is a closed book exam. No calculators, notes, or other aids are allowed.

More information

pykafka Release dev.2

pykafka Release dev.2 pykafka Release 2.8.0-dev.2 Apr 19, 2018 Contents 1 Getting Started 3 2 Using the librdkafka extension 5 3 Operational Tools 7 4 PyKafka or kafka-python? 9 5 Contributing 11 6 Support 13 i ii pykafka,

More information

Truffle A language implementation framework

Truffle A language implementation framework Truffle A language implementation framework Boris Spasojević Senior Researcher VM Research Group, Oracle Labs Slides based on previous talks given by Christian Wimmer, Christian Humer and Matthias Grimmer.

More information

PyPy - How to not write Virtual Machines for Dynamic Languages

PyPy - How to not write Virtual Machines for Dynamic Languages PyPy - How to not write Virtual Machines for Dynamic Languages Institut für Informatik Heinrich-Heine-Universität Düsseldorf ESUG 2007 Scope This talk is about: implementing dynamic languages (with a focus

More information

More Functions. CS 1111 Introduction to Programming. Spring 2019

More Functions. CS 1111 Introduction to Programming. Spring 2019 More Functions CS 1111 Introduction to Programming Spring 2019 [The Coder s Apprentice,, 8-8.3] Based in part on Agnostic Programming: Learning to Design and Test Basic Programming Algorithms by Kinga

More information

COMP 215: INTRO TO PROGRAM DESIGN. Prof. Chris Jermaine Chris Prof. Chris Dr. Chris

COMP 215: INTRO TO PROGRAM DESIGN. Prof. Chris Jermaine Chris Prof. Chris Dr. Chris COMP 215: INTRO TO PROGRAM DESIGN Prof. Chris Jermaine cmj4@cs.rice.edu Chris Prof. Chris Dr. Chris 1 This Class 50% of content: modern programming and program design The Java programming language will

More information

CPSC 217 L01 Midterm

CPSC 217 L01 Midterm CPSC 217 L01 Midterm Duration: 50 minutes 4 March 2010 This exam has 55 questions and 10 pages. This exam is closed book. No notes, books, calculators or electronic devices, or other assistance may be

More information

pytest-benchmark Release 2.5.0

pytest-benchmark Release 2.5.0 pytest-benchmark Release 2.5.0 September 13, 2015 Contents 1 Overview 3 1.1 pytest-benchmark............................................ 3 2 Installation 7 3 Usage 9 4 Reference 11 4.1 pytest_benchmark............................................

More information

Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1

Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1 CS 61A Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1 INSTRUCTIONS You have 1 hour to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,

More information

In addition to the correct answer, you MUST show all your work in order to receive full credit.

In addition to the correct answer, you MUST show all your work in order to receive full credit. In addition to the correct answer, you MUST show all your work in order to receive full credit. Questions Mark: Question1) Multiple Choice Questions /10 Question 2) Binary Trees /15 Question 3) Linked

More information

Programming environments. Introduction to Python. Adrian Copie, Ph.D.

Programming environments. Introduction to Python. Adrian Copie, Ph.D. Programming environments Introduction to Python Adrian Copie, Ph.D.! email: adrian.copie@info.uvt.ro, adrian.copie@e-uvt.ro UVT: room 050B 1 2 Bibliography 3 Mark Lutz - Learning Python (O Reilly) Leaning

More information

2

2 2 3 4 5 6 Open a terminal window and type python If on Windows open a Python IDE like IDLE At the prompt type hello world! >>> 'hello world!' 'hello world!' Python is an interpreted language The interpreter

More information

Accelerating Ruby with LLVM

Accelerating Ruby with LLVM Accelerating Ruby with LLVM Evan Phoenix Oct 2, 2009 RUBY RUBY Strongly, dynamically typed RUBY Unified Model RUBY Everything is an object RUBY 3.class # => Fixnum RUBY Every code context is equal RUBY

More information

par serge-sans-paille Ingénieur R&D en compil' à Quarkslab Chercheur associé à (feu) Télécom Bretagne Core dev Pythran

par serge-sans-paille Ingénieur R&D en compil' à Quarkslab Chercheur associé à (feu) Télécom Bretagne Core dev Pythran Python & Pro ling par serge-sans-paille Ingénieur R&D en compil' à Quarkslab Chercheur associé à (feu) Télécom Bretagne Core dev Pythran Premature optimization is the root... We should forget about small

More information

Lecture 1: Introduction to Python

Lecture 1: Introduction to Python Hendrik Weimer Institute for Theoretical Physics, Leibniz University Hannover Quantum Physics with Python, 04 April 2016 Goals of this course Learn to use the Python language for physics problems Master

More information

SAS Tricks and Techniques From the SNUG Committee. Bhupendra Pant University of Western Sydney College

SAS Tricks and Techniques From the SNUG Committee. Bhupendra Pant University of Western Sydney College SAS Tricks and Techniques From the SNUG Committee Bhupendra Pant University of Western Sydney College SAS Tricks and Techniques 1.Data Set Debugger in DMS 2.Recovering your SAS code from EG 3.Creating

More information

CSc 520 Principles of Programming Languages

CSc 520 Principles of Programming Languages CSc 520 Principles of Programming Languages 9: Scheme Metacircular Interpretation Christian Collberg collberg@cs.arizona.edu Department of Computer Science University of Arizona Copyright c 2005 Christian

More information

Unit Testing In Python

Unit Testing In Python Lab 13 Unit Testing In Python Lab Objective: One of the hardest parts of computer programming is ensuring that a program does what you expect it to do. For instance, a program may fail to meet specifications,

More information

Supplementary Test 1

Supplementary Test 1 Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 Supplementary Test 1 Question

More information

CS Programming Languages: Python

CS Programming Languages: Python CS 3101-1 - Programming Languages: Python Lecture 5: Exceptions / Daniel Bauer (bauer@cs.columbia.edu) October 08 2014 Daniel Bauer CS3101-1 Python - 05 - Exceptions / 1/35 Contents Exceptions Daniel Bauer

More information

Debug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args>

Debug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args> Page 1 of 5 Debug for GDB Users Basic Control To be useful, a debugger must be capable of basic process control. This functionally allows the user to create a debugging session and instruct the process

More information

FROM SCRIPT TO PACKAGES. good practices for hassle-free code reuse

FROM SCRIPT TO PACKAGES. good practices for hassle-free code reuse FROM SCRIPT TO PACKAGES good practices for hassle-free code reuse WHAT S THIS TUTORIAL IS ABOUT How to make your code usable by someone else WHO AM I? Contributor to numpy/scipy since 2007 Windows, Mac

More information

CptS 360 (System Programming) Unit 4: Debugging

CptS 360 (System Programming) Unit 4: Debugging CptS 360 (System Programming) Unit 4: Debugging Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2018 Motivation You re probably going to spend most of your code

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Parsing Scheme (+ (* 2 3) 1) * 1

Parsing Scheme (+ (* 2 3) 1) * 1 Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes

More information

When Virtual Hell Freezes OverReversing C++ Code. Gal

When Virtual Hell Freezes OverReversing C++ Code. Gal When Virtual Hell Freezes OverReversing C++ Code

More information

Guido van Rossum 9th LASER summer school, Sept. 2012

Guido van Rossum 9th LASER summer school, Sept. 2012 Guido van Rossum guido@python.org 9th LASER summer school, Sept. 2012 Async I/O is as old as computers But programmers prefer synchronous I/O Easier to understand Easier to write code for Fewer chances

More information

Runtime Environment. Part II May 8th Wednesday, May 8, 13

Runtime Environment. Part II May 8th Wednesday, May 8, 13 Runtime Environment Part II May 8th 2013 Wednesday, May 8, 13 Where We Are Source Code Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Machine

More information

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Speeding up Python. Antonio Gómez-Iglesias April 17th, 2015

Speeding up Python. Antonio Gómez-Iglesias April 17th, 2015 Speeding up Python Antonio Gómez-Iglesias agomez@tacc.utexas.edu April 17th, 2015 Why Python is nice, easy, development is fast However, Python is slow The bottlenecks can be rewritten: SWIG Boost.Python

More information