Python in a Hacker's Toolbox

Total Page:16

File Type:pdf, Size:1020Kb

Python in a Hacker's Toolbox Python in a hacker's toolbox v. 2016 Gynvael Coldwind Security PWNing Conference, Warszawa 2016 Keynote? Raczej prelekcja techniczna. O prelegencie All opinions expressed during this presentations are mine and mine alone. They are not opinions of my lawyer, barber and especially not my employer. Menu Sandboxing Język i VM Bezpieczeństwo RE Ta prezentacja zawiera fragmenty ● Data, data, data... ● "On the battlefield with the dragons" (+ Mateusz Jurczyk) ● "Ataki na systemy i sieci komputerowe" ● "Pwning (sometimes) with style - Dragons' notes on CTFs" (+ Mateusz Jurczyk) ● "Python in a hacker's toolbox" Język i VM Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Python Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Język rozwijany przez Python Software Foundation Python Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Język rozwijany przez Python Software Foundation Python Python Enhancement Proposal (w skrócie: PEP) Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Język rozwijany przez Python Software Foundation Python Python Enhancement Proposal (w skrócie: PEP) Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... CPython Brython CLPython Jython HotPy pyjs Python Implementacje PyMite PyPy pyvm SNAPpy RapydScript IronPython tinypy https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Jython Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Brython Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Python Implementacje IronPython https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... CPython Implementacja wzorcowa Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... CPython 2.7 3.X Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... O tym jest ta CPython prezentacja 2.7 3.X Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... 2c-python Compyler Cython Python Kompilatory GCC Nuitka Pyc Shed Skin unPython https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... py2app PyInstaller Bundlery cx_Freeze Python ("freezery") py2exe bbfreeze http://tynecki.pl/pdf/A-comparison-of-reverse-engineering-methods-for-Python-compiled-binaries-Piotr-Tynecki.pdf Python jako język programowania (1 IV) Python jako język programowania (1 IV) Python jako język programowania (1 IV) Python jako język programowania (1 IV) Python jako język programowania (1 IV) Python jako język programowania (1 IV) Python jako język programowania (1 IV) http://gynvael.coldwind.pl/?id=599 Python jako język programowania obiektowy dynamicznie typowany bardzo rozsądne inty masa bibliotek świetna introspekcja RE PY → PYC → PY def func(a): python -m compileall simple.py print(a+1) func(41) >>> print( PY → PYC → PY datetime.datetime.fromtimestamp(0x58206240)) 2016-11-07 12:15:12 znak nowej linii sygnatura wersji timestamp PY → PYC → PY zserializowany obiekt klasy code PY → PYC → PY >>> import marshal >>> marshal.loads(open("simple.pyc").read()[8:]) <code object <module> at 0x7fdcd3fa66b0, file "simple.py", line 1> PY → PYC → PY >>> import marshal >>> marshal.loads(open("simple.pyc").read()[8:]) <code object <module> at 0x7fdcd3fa66b0, file "simple.py", line 1> kod bajtowy maszyny stosowej >>> import dis >>> dis.dis(c) 1 0 LOAD_CONST 0 (<code object func at...>) 3 MAKE_FUNCTION 0 6 STORE_NAME 0 (func) 4 9 LOAD_NAME 0 (func) 12 LOAD_CONST 1 (41) 15 CALL_FUNCTION 1 18 POP_TOP 19 LOAD_CONST 2 (None) 22 RETURN_VALUE PY → PYC → PY func = MAKE_FUNCTION(CONST[0]) func(41) return None >>> import dis >>> dis.dis(c) 1 0 LOAD_CONST 0 (<code object func at...>) 3 MAKE_FUNCTION 0 6 STORE_NAME 0 (func) 4 9 LOAD_NAME 0 (func) 12 LOAD_CONST 1 (41) 15 CALL_FUNCTION 1 18 POP_TOP 19 LOAD_CONST 2 (None) 22 RETURN_VALUE PY → PYC → PY func = MAKE_FUNCTION(CONST[0]) >>> dis.dis(c.co_consts[0]) 2 0 LOAD_FAST 0 (a) 3 LOAD_CONST 1 (1) 6 BINARY_ADD 7 PRINT_ITEM 8 PRINT_NEWLINE 9 LOAD_CONST 0 (None) 12 RETURN_VALUE PY → PYC → PY func = MAKE_FUNCTION(CONST[0]) print(a+1) return None >>> dis.dis(c.co_consts[0]) 2 0 LOAD_FAST 0 (a) 3 LOAD_CONST 1 (1) 6 BINARY_ADD 7 PRINT_ITEM 8 PRINT_NEWLINE 9 LOAD_CONST 0 (None) 12 RETURN_VALUE PY → PYC → PY def func(a): def func(a): print(a+1) print(a+1) return None func(41) func(41) return None Easy Python Decompiler - https://sourceforge.net/projects/easypythondecompiler/ Decompyle++: https://github.com/zrax/pycdc uncompyle2: https://github.com/Mysterie/uncompyle2 Kod bajtowy a wersje CPython http://gynvael.coldwind.pl/rebook/py_opcodes.html Przykład RE What’s wrong with this? (Hack.lu 2013, 250) hello.tar What’s wrong with this? (Hack.lu 2013, 250) library.zip ... __main__hello__.pyc ... What’s wrong with this? (Hack.lu 2013, 250) __main__hello__.pyc http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html [Names] 'sys' 'hashlib' 'sha256' 'dis' 'multiprocessing' 'UserList' 'encrypt_string' 'rot_chr' 'SECRET' 'argv' What’s wrong with this? (Hack.lu 2013, 250) __main__hello__.pyc http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html [Names] [Code] 'sys' Object Name: encrypt_string 'hashlib' ... 'sha256' [Disassembly] 'dis' 0 BUILD_LIST 0 'multiprocessing' 3 STORE_FAST 1: new_str 'UserList' 6 SETUP_LOOP 99 (to 108) 'encrypt_string' 9 LOAD_GLOBAL 0: enumerate 'rot_chr' 12 LOAD_FAST 0: s 'SECRET' 15 CALL_FUNCTION 1 'argv' 18 <INVALID> What’s wrong with this? (Hack.lu 2013, 250) __main__hello__.pyc http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html # Source Generated with Decompyle++ [Names] # File: __main__hello__.pyc (...) 'sys' 'hashlib' import sys 'sha256' import dis 'dis' import multiprocessing 'multiprocessing' import UserList 'UserList' 'encrypt_string' def encrypt_string(s): 'rot_chr' pass 'SECRET' # WARNING: Decompyle incomplete 'argv' What’s wrong with this? (Hack.lu 2013, 250) Autorzy zadania zmodyfikowali kod bajtowy CPython. What’s wrong with this? (Hack.lu 2013, 250) Autorzy zadania zmodyfikowali kod bajtowy CPython. Na przykład: ... 114 LOAD_FAST 1: new_str 117 CALL_FUNCTION 1 120 IMPORT_STAR <the end> What’s wrong with this? (Hack.lu 2013, 250) Autorzy zadania zmodyfikowali kod bajtowy CPython. Na przykład: ... 114 LOAD_FAST 1: new_str 117 CALL_FUNCTION 1 120 IMPORT_STAR <the end> #define RETURN_VALUE 83 #define IMPORT_STAR 84 What’s wrong with this? (Hack.lu 2013, 250) 53 ↔ 54 62 ↔ 63 44 ↔ 45 19 ↔ 18 57 ↔ 58 What’s wrong with this? (Hack.lu 2013, 250) 53 ↔ 54 DELETE_SLICE vs STORE_MAP 62 ↔ 63 BINARY_LSHIFT vs BINARY_RSHIFT 44 ↔ 45 ? vs ? 19 ↔ 18 BINARY_POWER vs ? 57 ↔ 58 INPLACE_MULTIPLY vs INPLACE_DIVIDE What’s wrong with this? (Hack.lu 2013, 250) BUILD_LIST 0 STORE_FAST 1 (new_str) encrypt_string SETUP_LOOP 98 (to 107) ... GET_ITER FOR_ITER 85 (to 107) ... COMPARE_OP 2 (==) POP_BLOCK POP_JUMP_IF_FALSE 68 ... RETURN_VALUE LOAD_FAST 1 (new_str) LOAD_FAST 1 (new_str) ... ... JUMP_ABSOLUTE 19 JUMP_ABSOLUTE 19 What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) CALL_FUNCTION 1 LOAD_CONST 1 (33) BINARY_SUB LOAD_FAST 1 (amount) BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) CALL_FUNCTION 1 LOAD_CONST 1 (33) BINARY_SUB LOAD_FAST 1 (amount) BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) <c> CALL_FUNCTION 1 LOAD_CONST 1 (33) BINARY_SUB LOAD_FAST 1 (amount) <element na stosie> BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) <c> CALL_FUNCTION 1 ord(c) LOAD_CONST 1 (33) BINARY_SUB LOAD_FAST 1 (amount) BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) <c> CALL_FUNCTION 1 ord(c) LOAD_CONST 1 (33) ord(c) <33> BINARY_SUB LOAD_FAST 1 (amount) BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) <c> CALL_FUNCTION 1 ord(c) LOAD_CONST 1 (33) ord(c) <33> BINARY_SUB ord(c)-33 LOAD_FAST 1 (amount) BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) <c> CALL_FUNCTION 1 ord(c) LOAD_CONST 1 (33) ord(c) <33> BINARY_SUB ord(c)-33 LOAD_FAST 1 (amount) ord(c)-33 <amount> BINARY_ADD LOAD_CONST 2 (94) BINARY_MODULE LOAD_CONST 1 (33) BINARY_ADD CALL_FUNCTION 0 RETURN_VALUE What’s wrong with this? (Hack.lu 2013, 250) LOAD_GLOBAL 0 (chr) rot_chr LOAD_GLOBAL 1 (ord) LOAD_FAST 0 (c) <c> CALL_FUNCTION
Recommended publications
  • A Practical Solution for Scripting Language Compilers
    A Practical Solution for Scripting Language Compilers Paul Biggar, Edsko de Vries, David Gregg Department of Computer Science, Trinity College Dublin, Dublin 2, Ireland Abstract Although scripting languages are becoming increasingly popular, even mature script- ing language implementations remain interpreted. Several compilers and reimplemen- tations have been attempted, generally focusing on performance. Based on our survey of these reimplementations, we determine that there are three important features of scripting languages that are difficult to compile or reimplement. Since scripting languages are defined primarily through the semantics of their original implementations, they often change semantics between releases. They provide C APIs, used both for foreign-function interfaces and to write third-party extensions. These APIs typically have tight integration with the original implementation, and are used to providelarge standard libraries, which are difficult to re-use, and costly to reimplement. Finally, they support run-time code generation. These features make the important goal of correctness difficult to achieve for compilers and reimplementations. We present a technique to support these features in an ahead-of-time compiler for PHP. Our technique uses the original PHP implementation through the provided C API, both in our compiler, and in our generated code. We support all of these impor- tant scripting language features, particularly focusing on the correctness of compiled programs. Additionally, our approach allows us to automatically support limited fu- ture language changes. We present a discussion and performance evaluation of this technique. Key words: Compiler, Scripting Language 1. Motivation Although scripting languages1 are becoming increasingly popular, most scripting language implementations remain interpreted. Typically, these implementations are slow, between one and two orders of magnitude slower than C.
    [Show full text]
  • An Implementation of Python for Racket
    An Implementation of Python for Racket Pedro Palma Ramos António Menezes Leitão INESC-ID, Instituto Superior Técnico, INESC-ID, Instituto Superior Técnico, Universidade de Lisboa Universidade de Lisboa Rua Alves Redol 9 Rua Alves Redol 9 Lisboa, Portugal Lisboa, Portugal [email protected] [email protected] ABSTRACT Keywords Racket is a descendent of Scheme that is widely used as a Python; Racket; Language implementations; Compilers first language for teaching computer science. To this end, Racket provides DrRacket, a simple but pedagogic IDE. On the other hand, Python is becoming increasingly popular 1. INTRODUCTION in a variety of areas, most notably among novice program- The Racket programming language is a descendent of Scheme, mers. This paper presents an implementation of Python a language that is well-known for its use in introductory for Racket which allows programmers to use DrRacket with programming courses. Racket comes with DrRacket, a ped- Python code, as well as adding Python support for other Dr- agogic IDE [2], used in many schools around the world, as Racket based tools. Our implementation also allows Racket it provides a simple and straightforward interface aimed at programs to take advantage of Python libraries, thus signif- inexperienced programmers. Racket provides different lan- icantly enlarging the number of usable libraries in Racket. guage levels, each one supporting more advanced features, that are used in different phases of the courses, allowing Our proposed solution involves compiling Python code into students to benefit from a smoother learning curve. Fur- semantically equivalent Racket source code. For the run- thermore, Racket and DrRacket support the development of time implementation, we present two different strategies: additional programming languages [13].
    [Show full text]
  • Proseminar Python - Python Bindings
    Proseminar Python - Python Bindings Sven Fischer Student an der TU-Dresden [email protected] Abstract Diese Arbeit beschaftigt¨ sich damit, einen Einblick in die Benut- zung von externen Bibliotheken in Python zu geben und fuhrt¨ den Leser in das Schreiben von eigenen Erweiterungen ein. Daruber¨ hinaus wird darauf eingegangen, wie Projekte in anderen Program- miersprachen Python benutzen konnen.¨ Weiterhin wird kurz auf verschiedene andere Moglichkeiten¨ eingegangen, Python oder Py- thons Benutzung zu erweitern und zu verandern:¨ durch Kompilati- on, Mischen“ mit oder Ubersetzen¨ in anderen Sprachen, oder spe- ” zielle Interpreter. Abbildung 1. Vergleich der Moglichkeiten¨ Python zu erwei- tern (links) und Python einzubetten (rechts). Categories and Subject Descriptors D.3.3 [Programming Lan- guages]: Language Constructs and Features—Modules, packages 1. Daten von C nach Python konvertieren General Terms Languages, Documentation 2. Python Funktion mit konvertierten Werten aufrufen Keywords Python, Extension, Embedding, Library 3. Ergebnis von Python zuruck¨ nach C konvertieren 1. Einfuhrung¨ Diese Konvertierung ist auch das großte¨ Hindernis beim Ver- 1 Python wird mit einer umfangreichen Standartbibliothek ausgelie- knupfen¨ von Python und C , zumindest ist es mit einigem Aufwand fert. Trotzdem gibt es Grunde,¨ warum man Python um verschiedene verbunden. externe Bibliotheken erweitern mochte.¨ Ein Beispiel dafur¨ ware¨ die Es gibt einige Projekte, die sich mit dem Verandern¨ und Erwei- ¨ Geschwindigkeit, die bei Python als interpretierter Sprache nicht tern der Sprache Python beschaftigen.¨ Einen kurzen Uberblick uber¨ immer den Anforderungen entspricht. Weiterhin gibt es genugend¨ einige Moglichkeiten¨ gebe ich in Abschnitt4. Dort gehe ich auf Software von Drittanbietern, welche man in Python nutzbar ma- zwei Python-Interpreter neben dem in der Standard-Distribution chen will - ohne sie in Python zu ubersetzen.¨ Darauf gehe ich in enthaltenen ein und zeige Moglichkeiten¨ auf, Python in andere Abschnitt2 ein.
    [Show full text]
  • Efficient Use of Python on the Clusters
    Efficient use of Python on the clusters Ariel Lozano CÉCI training November 21, 2018 Outline I Analyze our code with profiling tools: I cpu: cProfile, line_profiler, kernprof I memory: memory_profiler, mprof I Being a highly abstract dynamically typed language, how to make a more efficient use of hardware internals? I Numpy and Scipy ecosystem (mainly wrappers to C/Fortran compiled code) I binding to compiled code: interfaces between python and compiled modules I compiling: tools to compile python code I parallelism: modules to exploit multicores Sieve of eratostenes Algorithm to find all prime numbers up to any given limit. Ex: Find all the prime numbers less than or equal to 25: I 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Cross out every number displaced by 2 after 2 up to the limit: I 23 45 67 89 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Move to next n non crossed, cross out each non crossed number displaced by n: I 23 45 67 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 I 2 3 45 67 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 The remaining numbers non crossed in the list are all the primes below limit. 2 Trivial optimization: jump directlyp to n to start crossing out. Then, n must loop only up to limit.
    [Show full text]
  • Shed Skin Documentation Release V0.9.4
    Shed Skin Documentation Release v0.9.4 Mark Dufour the Shed Skin contributors Mar 16, 2017 Contents 1 An experimental (restricted-Python)-to-C++ compiler1 2 Documentation 3 2.1 Shed Skin documentation........................................3 2.1.1 Introduction...........................................3 2.1.2 Typing restrictions.......................................3 2.1.3 Python subset restrictions....................................4 2.1.4 Library limitations.......................................5 2.1.5 Installation...........................................6 2.1.5.1 Windows........................................6 2.1.5.2 UNIX.........................................6 2.1.5.2.1 Using a package manager..........................6 2.1.5.2.2 Manual installation.............................6 2.1.5.3 OSX..........................................7 2.1.5.3.1 Manual installation.............................7 2.1.6 Compiling a standalone program................................8 2.1.7 Generating an extension module................................8 2.1.7.1 Limitations.......................................9 2.1.7.2 Numpy integration...................................9 2.1.8 Distributing binaries...................................... 10 2.1.8.1 Windows........................................ 10 2.1.8.2 UNIX......................................... 10 2.1.9 Multiprocessing......................................... 10 2.1.10 Calling C/C++ code....................................... 11 2.1.10.1 Standard library...................................
    [Show full text]
  • A Python Implementation for Racket
    PyonR: A Python Implementation for Racket Pedro Alexandre Henriques Palma Ramos Thesis to obtain the Master of Science Degree in Information Systems and Computer Engineering Supervisor: António Paulo Teles de Menezes Correia Leitão Examination Committee Chairperson: Prof. Dr. José Manuel da Costa Alves Marques Supervisor: Prof. Dr. António Paulo Teles de Menezes Correia Leitão Member of the Committee: Prof. Dr. João Coelho Garcia October 2014 ii Agradecimentos Agradec¸o... Em primeiro lugar ao Prof. Antonio´ Leitao,˜ por me ter dado a oportunidade de participar no projecto Rosetta com esta tese de mestrado, por todos os sabios´ conselhos e pelos momentos de discussao˜ e elucidac¸ao˜ que se proporcionaram ao longo deste trabalho. Aos meus pais excepcionais e a` minha mana preferida, por me terem aturado e suportado ao longo destes quase 23 anos e sobretudo pelo incondicional apoio durante estes 5 anos de formac¸ao˜ superior. Ao pessoal do Grupo de Arquitectura e Computac¸ao˜ (Hugo Correia, Sara Proenc¸a, Francisco Freire, Pedro Alfaiate, Bruno Ferreira, Guilherme Ferreira, Inesˆ Caetano e Carmo Cardoso), por todas as sug- estoes˜ e pelo inestimavel´ feedback em artigos e apresentac¸oes.˜ Aos amigos em Tomar (Rodrigo Carrao,˜ Hugo Matos, Andre´ Marques e Rui Santos) e em Lisboa (Diogo da Silva, Nuno Silva, Pedro Engana, Kaguedes, Clara Paiva e Odemira), por terem estado pre- sentes, duma forma ou doutra, nos essenciais momentos de lazer. A` Fundac¸ao˜ para a Cienciaˆ e Tecnologia (FCT) e ao INESC-ID pelo financiamento e acolhimento atraves´ da atribuic¸ao˜ de uma bolsa de investigac¸ao˜ no ambitoˆ dos contratos Pest-OE/EEI/LA0021/2013 e PTDC/ATP-AQI/5224/2012.
    [Show full text]
  • Table of Contents
    Table of Contents Introduction 1.1 Dedication 1.2 Preface 1.3 About Python 1.4 Installation 1.5 First Steps 1.6 Basics 1.7 Operators and Expressions 1.8 Control flow 1.9 Functions 1.10 Modules 1.11 Data Structures 1.12 Problem Solving 1.13 Object Oriented Programming 1.14 Input and Output 1.15 Exceptions 1.16 Standard Library 1.17 More 1.18 What Next 1.19 Appendix: FLOSS 1.20 Appendix: About 1.21 Appendix: Revision History 1.22 Appendix: Translations 1.23 Appendix: Translation How-to 1.24 Feedback 1.25 1 Introduction A Byte of Python "A Byte of Python" is a free book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save text files, then this is the book for you. For Python version 3 This book will teach you to use Python version 3. There will also be guidance for you to adapt to the older and more common Python version 2 in the book. Who reads A Byte of Python? Here are what people are saying about the book: This is the book that got me into programming almost a decade ago. Thank you @swaroopch. You changed my life. -- Stefan Froelich I am writing this email to thank you for the great help your book has done for me! It was a really good book that I enjoyed thoroughly. As a 15 year old who has never done programming before, trying to learn Python online was difficult and I couldn't understand anything.
    [Show full text]
  • Python in a Nutshell Part I: Python, Ipython, Language and OOP
    Python in a Nutshell Part I: Python, ipython, language and OOP Manel Velasco,1 PhD and Alexandre Perera,1;2 PhD 1Departament d'Enginyeria de Sistemes, Automatica i Informatica Industrial (ESAII) Universitat Politecnica de Catalunya 2Centro de Investigacion Biomedica en Red en Bioingenieria, Biomateriales y Nanomedicina (CIBER-BBN) [email protected] [email protected] Introduction to Python for Engineering and Statistics Febraury, 2013 Introduction Working with Python Getting Started With Python Functions and Object Oriented Programming ContentsI 1 Introduction Why Learn Python Python History Installing Python Python Resources 2 Working with Python Workflow ipython vs. CLI Text Editors IDEs Notebook 3 Getting Started With Python Introduction Velasco and Perera Python in a Nutshell Introduction Working with Python Getting Started With Python Functions and Object Oriented Programming ContentsII Basic Types Mutable and immutable Controlling execution flow Exception handling 4 Functions and Object Oriented Programming Defining New Functions Decorators Writing Scripts and New Modules Input and Output Standard Library Object-Oriented Programming Velasco and Perera Python in a Nutshell Introduction Why Learn Python Working with Python Python History Getting Started With Python Installing Python Functions and Object Oriented Programming Python Resources Outline 1 Introduction Why Learn Python Python History Installing Python Python Resources 2 Working with Python Workflow ipython vs. CLI Text Editors IDEs Notebook 3 Getting Started With
    [Show full text]
  • Nuitka User Manual Contents
    Nuitka User Manual Contents Overview 1 Usage 1 Requirements 1 Command Line 3 Installation 3 License 3 Tutorial Setup and build on Windows 3 Setup 4 Install Python 4 Install Nuitka 4 Write some code and test 4 Create a folder for the Python code 4 Test your program 4 Build it using 4 Run it 5 Distribute 5 Use Cases 5 Use Case 1 - Program compilation with all modules embedded 5 Use Case 2 - Extension Module compilation 6 Use Case 3 - Package compilation 7 Use Case 4 - Program Distribution 7 Tweaks 8 Icons 8 Splash screen 9 Typical Problems 9 Memory issues and compiler bugs 9 Avoid 32 bit C compiler/assembler memory limits 9 Use LTO compilation or not 10 Switch the C compiler to clang 10 Add a larger swap file to your embedded Linux 10 Limit the amount of compilation jobs 10 Dynamic sys.path 10 Missing data files in standalone 10 Missing DLLs in standalone 10 Dependency creep in standalone 10 Onefile: Finding files 11 Windows Programs without console give no errors 11 Tips 11 Nuitka Options in the code 11 Python command line flags 12 Caching compilation results 12 Control where Caches live 12 Runners 12 Fastest C Compilers 12 Unexpected Slowdowns 13 Standalone executables and dependencies 13 Windows errors with resources 13 Windows standalone program redistribuation 13 Detecting Nuitka at run time 14 Performance 14 pystone results 14 Where to go next 14 Follow me on Twitter 14 Report issues or bugs 14 Word of Warning 15 Join Nuitka 15 Donations 15 Unsupported functionality 15 The co_code attribute of code objects 15 PDB 16 Optimization 16
    [Show full text]
  • O'reilly Books
    Intellectual Property and Open Source ,ip_roadmap.18464 Page ii Thursday, July 3, 2008 10:38 AM Other resources from O’Reilly Related titles Applied Software Producing Open Source Management Software Hackers & Painters The Cathedral & the Bazaar Open Sources Understanding Open Open Sources 2.0 Source and Free Software Licensing oreilly.com oreilly.com is more than a complete catalog of O'Reilly books. You'll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers inter- ested in open and emerging technologies, including new platforms, programming languages, and operating sys- tems. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in documenting the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online reference library for programmers and IT professionals. Conduct searches across more than 1,000 books. Sub- scribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or simply flip to the page you need. Try it today for free. main.title Page iii Monday, May 19, 2008 11:21 AM Intellectual PropertyTomcat ™ andThe Open Definitive Source Guide Jason Brittain and Ian VanF. Darwin Lindberg Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo Intellectual Property and Open Source by Van Lindberg Copyright © 2008 Van Lindberg. All rights reserved. Printed in the United States of America.
    [Show full text]
  • Py++ Project Report
    Py++ Project Report COMS-E6998-3 Advanced Programming Languages and Compilers Fall 2012 Team Members:- Abhas Bodas ([email protected]) Jared Pochtar ([email protected]) Submitted By:- Abhas Bodas ([email protected]) Project Guide:- Prof. Alfred Aho ([email protected]) Page 1 Contents 1. Overview …...................…...................…...................…...................…....................... 3 2. Background Work …...................…...................…...................…..............…............... 4 3. Architecture …...................…...................…...................…...................…..............….. 5 4. Implementation …...................…...................…...................…...................…................ 6 5. Areas of focus / Optimizations …...................…...................…...................…............... 9 6. Results / Conclusion …...................…...................…...................…...................…....... 10 7. Appendix …...................…...................…...................…...................….................…..... 11 Page 2 1. Overview Our project, Py++ paves the way for a compiled Python with speed as the primary focus. Py++ aims to generate fast C/C++ from Python code. We have used the CPython C-API for most of the built in types, objects, and functions. CPython has extensive standard libraries and builtin object support. These objects are quite efficient -- a set, dictionary, or list implementation written in pure C shouldn’t care whether it’s called in an
    [Show full text]
  • Seq: a High-Performance Language for Bioinformatics
    1 1 Seq: A High-Performance Language for Bioinformatics 2 3 ANONYMOUS AUTHOR(S)∗ 4 5 The scope and scale of biological data is increasing at an exponential rate, as technologies like 6 next-generation sequencing are becoming radically cheaper and more prevalent. Over the last two 7 decades, the cost of sequencing a genome has dropped from $100 million to nearly $100—a factor of 6 8 over 10 —and the amount of data to be analyzed has increased proportionally. Yet, as Moore’s Law continues to slow, computational biologists can no longer rely on computing hardware to 9 compensate for the ever-increasing size of biological datasets. In a field where many researchers are 10 primarily focused on biological analysis over computational optimization, the unfortunate solution 11 to this problem is often to simply buy larger and faster machines. 12 Here, we introduce Seq, the first language tailored specifically to bioinformatics, which marries 13 the ease and productivity of Python with C-like performance. Seq is a subset of Python—and in 14 many cases a drop-in replacement—yet also incorporates novel bioinformatics- and computational 15 genomics-oriented data types, language constructs and optimizations. Seq enables users to write 16 high-level, Pythonic code without having to worry about low-level or domain-specific optimizations, 17 and allows for seamless expression of the algorithms, idioms and patterns found in many genomics or 18 bioinformatics applications. On equivalent CPython code, Seq attains a performance improvement of 19 up to two orders of magnitude, and a 175× improvement once domain-specific language features and optimizations are used.
    [Show full text]