Pybind11 Documentation

Total Page:16

File Type:pdf, Size:1020Kb

Pybind11 Documentation pybind11 Documentation Wenzel Jakob Sep 25, 2021 CONTENTS 1 Changelog 3 2 Upgrade guide 27 3 Installing the library 35 4 First steps 37 5 Object-oriented code 42 6 Build systems 50 7 Functions 59 8 Classes 68 9 Exceptions 88 10 Smart pointers 94 11 Type conversions 97 12 Python C++ interface 117 13 Embedding the interpreter 131 14 Miscellaneous 136 15 Frequently asked questions 142 16 Benchmark 148 17 Limitations 151 18 Reference 153 19 CMake helpers 170 Bibliography 174 Index 175 i pybind11 Documentation pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection. The main issue with Boost.Python—and the reason for creating such a similar project—is Boost. Boost is an enor- mously large and complex suite of utility libraries that works with almost every C++ compiler in existence. This compatibility has its cost: arcane template tricks and workarounds are necessary to support the oldest and buggiest of compiler specimens. Now that C++11-compatible compilers are widely available, this heavy machinery has become an excessively large and unnecessary dependency. Think of this library as a tiny self-contained version of Boost.Python with everything stripped away that isn’t relevant for binding generation. Without comments, the core header files only require ~4K lines of code and depend on Python (2.7 or 3.5+, or PyPy) and the C++ standard library. This compact implementation was possible thanks to some of the new C++11 language features (specifically: tuples, lambda functions and variadic templates). Since its creation, this library has grown beyond Boost.Python in many ways, leading to dramatically simpler binding code in many common situations. Tutorial and reference documentation is provided at pybind11.readthedocs.io. A PDF version of the manual is available here. And the source code is always available at github.com/pybind/pybind11. Core features pybind11 can map the following core C++ features to Python: • Functions accepting and returning custom data structures per value, reference, or pointer • Instance methods and static methods • Overloaded functions • Instance attributes and static attributes • Arbitrary exception types • Enumerations • Callbacks • Iterators and ranges • Custom operators • Single and multiple inheritance • STL data structures • Smart pointers with reference counting like std::shared_ptr • Internal references with correct reference counting • C++ classes with virtual (and pure virtual) methods can be extended in Python Goodies In addition to the core functionality, pybind11 provides some extra goodies: • Python 2.7, 3.5+, and PyPy/PyPy3 7.3 are supported with an implementation-agnostic interface. • It is possible to bind C++11 lambda functions with captured variables. The lambda capture data is stored inside the resulting Python function object. • pybind11 uses C++11 move constructors and move assignment operators whenever possible to efficiently trans- fer custom data types. CONTENTS 1 pybind11 Documentation • It’s easy to expose the internal storage of custom data types through Pythons’ buffer protocols. This is handy e.g.for fast conversion between C++ matrix classes like Eigen and NumPy without expensive copy operations. • pybind11 can automatically vectorize functions so that they are transparently applied to all entries of one or more NumPy array arguments. • Python’s slice-based access and assignment operations can be supported with just a few lines of code. • Everything is contained in just a few header files; there is no need to link against any additional libraries. • Binaries are generally smaller by a factor of at least 2 compared to equivalent bindings generated by Boost.Python. A recent pybind11 conversion of PyRosetta, an enormous Boost.Python binding project, reported a binary size reduction of 5.4x and compile time reduction by 5.8x. • Function signatures are precomputed at compile time (using constexpr), leading to smaller binaries. • With little extra effort, C++ types can be pickled and unpickled similar to regular Python objects. Supported compilers 1. Clang/LLVM 3.3 or newer (for Apple Xcode’s clang, this is 5.0.0 or newer) 2. GCC 4.8 or newer 3. Microsoft Visual Studio 2015 Update 3 or newer 4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI) 5. Cygwin/GCC (previously tested on 2.5.1) 6. NVCC (CUDA 11.0 tested in CI) 7. NVIDIA PGI (20.9 tested in CI) About This project was created by Wenzel Jakob. Significant features and/or improvements to the code were contributed by Jonas Adler, Lori A. Burns, Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houlis- ton, Axel Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov Johan Mabille, Tomasz Mi ˛asko, Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart. We thank Google for a generous financial contribution to the continuous integration infrastructure used by this project. Contributing See the contributing guide for information on building and contributing to pybind11. License pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license. CONTENTS 2 CHAPTER ONE CHANGELOG Starting with version 1.8.0, pybind11 releases use a semantic versioning policy. 1.1 v2.8.0 (WIP) New features: • Added py::raise_from to enable chaining exceptions. #3215 • Allow exception translators to be optionally registered local to a module instead of applying globally across all pybind11 modules. Use register_local_exception_translator(ExceptionTranslator&& translator) instead of register_exception_translator(ExceptionTranslator&& translator) to keep your exception remapping code local to the module. #2650 • Add make_simple_namespace function for instantiating Python SimpleNamespace objects. #2840 • pybind11::scoped_interpreter and initialize_interpreter have new arguments to allow sys.argv initialization. #2341 • Allow Python builtins to be used as callbacks in CPython. #1413 • Added view to view arrays with a different datatype. #987 • Implemented reshape on arrays. #984 • Enable defining custom __new__ methods on classes by fixing bug preventing overriding methods if they have non-pybind11 siblings. #3265 • Add make_value_iterator(), and fix make_key_iterator() to return references instead of copies. #3293 • pybind11::custom_type_setup was added, for customizing the PyHeapTypeObject corresponding to a class, which may be useful for enabling garbage collection support, among other things. #3287 Changes: • Set __file__ constant when running eval_file in an embedded interpreter. #3233 • Python objects and (C++17) std::optional now accepted in py::slice constructor. #1101 • The pybind11 proxy types str, bytes, bytearray, tuple, list now consistently support passing ssize_t values for sizes and indexes. Previously, only size_t was accepted in several interfaces. #3219 • Avoid evaluating PYBIND11_TLS_REPLACE_VALUE arguments more than once. #3290 Fixes: • Bug fix: enum value’s __int__ returning non-int when underlying type is bool or of char type. #1334 3 pybind11 Documentation • Fixes bug in setting error state in Capsule’s pointer methods. #3261 • A long-standing memory leak in py::cpp_function::initialize was fixed. #3229 • Fixes thread safety for some pybind11::type_caster which require lifetime extension, such as for std::string_view. #3237 • Restore compatibility with gcc 4.8.4 as distributed by ubuntu-trusty, linuxmint-17. #3270 Build system improvements: • Fix regression in CMake Python package config: improper use of absolute path. #3144 • Cached Python version information could become stale when CMake was re-run with a different Python version. The build system now detects this and updates this information. #3299 • Specified UTF8-encoding in setup.py calls of open(). #3137 • Fix a harmless warning from CMake 3.21 with the classic Python discovery. #3220 Backend and tidying up: • Reduced thread-local storage required for keeping alive temporary data for type conversion to one key per ABI version, rather than one key per extension module. This makes the total thread-local storage required by pybind11 2 keys per ABI version. #3275 • Optimize NumPy array construction with additional moves. #3183 • Conversion to std::string and std::string_view now avoids making an extra copy of the data on Python >= 3.3. #3257 • Remove const modifier from certain C++ methods on Python collections (list, set, dict) such as (clear(), append(), insert(), etc. ) and annotated them with py-non-const. • Enable readability clang-tidy-const-return and remove useless consts. #3254 #3194 • The clang-tidy google-explicit-constructor option was enabled. #3250 • Mark a pytype move constructor as noexcept (perf). #3236 • Enable clang-tidy check to guard against inheritance slicing. #3210 • Legacy warning suppression pragma were removed from eigen.h. On Unix platforms, please use -isystem for Eigen include directories, to suppress compiler warnings originating from Eigen headers. Note that CMake does this by default. No adjustments are needed for Windows. #3198 • Format pybind11 with isort consistent ordering of imports #3195 • The warnings-suppression
Recommended publications
  • Ironpython in Action
    IronPytho IN ACTION Michael J. Foord Christian Muirhead FOREWORD BY JIM HUGUNIN MANNING IronPython in Action Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> IronPython in Action MICHAEL J. FOORD CHRISTIAN MUIRHEAD MANNING Greenwich (74° w. long.) Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. Sound View Court 3B fax: (609) 877-8256 Greenwich, CT 06830 email: [email protected] ©2009 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15% recycled and processed without the use of elemental chlorine.
    [Show full text]
  • RZ/G Verified Linux Package for 64Bit Kernel V1.0.5-RT Release Note For
    Release Note RZ/G Verified Linux Package for 64bit kernel Version 1.0.5-RT R01TU0311EJ0102 Rev. 1.02 Release Note for HTML5 Sep 7, 2020 Introduction This release note describes the contents, building procedures for HTML5 (Gecko) and important points of the RZ/G Verified Linux Package for 64bit kernel (hereinafter referred to as “VLP64”). In this release, Linux packages for HTML5 is preliminary and provided AS IS with no warranty. If you need information to build Linux BSPs without a GUI Framework of HTML5, please refer to “RZ/G Verified Linux Package for 64bit kernel Version 1.0.5-RT Release Note”. Contents 1. Release Items ................................................................................................................. 2 2. Build environment .......................................................................................................... 4 3. Building Instructions ...................................................................................................... 6 3.1 Setup the Linux Host PC to build images ................................................................................. 6 3.2 Building images to run on the board ........................................................................................ 8 3.3 Building SDK ............................................................................................................................. 12 4. Components ................................................................................................................. 13 5. Restrictions
    [Show full text]
  • 102-401-08 3 Fiches SOFTW.Indd
    PYPY to be adapted to new platforms, to be used in education Scope and to give new answers to security questions. Traditionally, fl exible computer languages allow to write a program in short time but the program then runs slow- Contribution to standardization er at the end-user. Inversely, rather static languages run 0101 faster but are tedious to write programs in. Today, the and interoperability issues most used fl exible and productive computer languages Pypy does not contribute to formal standardization proc- are hard to get to run fast, particularly on small devices. esses. However, Pypy’s Python implementation is practi- During its EU project phase 2004-2007 Pypy challenged cally interoperable and compatible with many environ- this compromise between fl exibility and speed. Using the ments. Each night, around 12 000 automatic tests ensure platform developed in Pypy, language interpreters can that it remains robust and compatible to the mainline now be written at a higher level of abstraction. Pypy au- Python implementation. tomatically produces effi cient versions of such language interpreters for hardware and virtual target environ- Target users / sectors in business ments. Concrete examples include a full Python Inter- 010101 10 preter, whose further development is partially funded by and society the Google Open Source Center – Google itself being a Potential users are developers and companies who have strong user of Python. Pypy also showcases a new way of special needs for using productive dynamic computer combining agile open-source development and contrac- languages. tual research. It has developed methods and tools that support similar projects in the future.
    [Show full text]
  • Scons API Docs Version 4.2
    SCons API Docs version 4.2 SCons Project July 31, 2021 Contents SCons Project API Documentation 1 SCons package 1 Module contents 1 Subpackages 1 SCons.Node package 1 Submodules 1 SCons.Node.Alias module 1 SCons.Node.FS module 9 SCons.Node.Python module 68 Module contents 76 SCons.Platform package 85 Submodules 85 SCons.Platform.aix module 85 SCons.Platform.cygwin module 85 SCons.Platform.darwin module 86 SCons.Platform.hpux module 86 SCons.Platform.irix module 86 SCons.Platform.mingw module 86 SCons.Platform.os2 module 86 SCons.Platform.posix module 86 SCons.Platform.sunos module 86 SCons.Platform.virtualenv module 87 SCons.Platform.win32 module 87 Module contents 87 SCons.Scanner package 89 Submodules 89 SCons.Scanner.C module 89 SCons.Scanner.D module 93 SCons.Scanner.Dir module 93 SCons.Scanner.Fortran module 94 SCons.Scanner.IDL module 94 SCons.Scanner.LaTeX module 94 SCons.Scanner.Prog module 96 SCons.Scanner.RC module 96 SCons.Scanner.SWIG module 96 Module contents 96 SCons.Script package 99 Submodules 99 SCons.Script.Interactive module 99 SCons.Script.Main module 101 SCons.Script.SConsOptions module 108 SCons.Script.SConscript module 115 Module contents 122 SCons.Tool package 123 Module contents 123 SCons.Variables package 125 Submodules 125 SCons.Variables.BoolVariable module 125 SCons.Variables.EnumVariable module 125 SCons.Variables.ListVariable module 126 SCons.Variables.PackageVariable module 126 SCons.Variables.PathVariable module 127 Module contents 127 SCons.compat package 129 Module contents 129 Submodules 129 SCons.Action
    [Show full text]
  • Porting of Micropython to LEON Platforms
    Porting of MicroPython to LEON Platforms Damien P. George George Robotics Limited, Cambridge, UK TEC-ED & TEC-SW Final Presentation Days ESTEC, 10th June 2016 George Robotics Limited (UK) I a limited company in the UK, founded in January 2014 I specialising in embedded systems I hardware: design, manufacturing (via 3rd party), sales I software: development and support of MicroPython code D.P. George (George Robotics Ltd) MicroPython on LEON 2/21 Motivation for MicroPython Electronics circuits now pack an enor- mous amount of functionality in a tiny package. Need a way to control all these sophisti- cated devices. Scripting languages enable rapid development. Is it possible to put Python on a microcontroller? Why is it hard? I Very little memory (RAM, ROM) on a microcontroller. D.P. George (George Robotics Ltd) MicroPython on LEON 3/21 Why Python? I High-level language with powerful features (classes, list comprehension, generators, exceptions, . ). I Large existing community. I Very easy to learn, powerful for advanced users: shallow but long learning curve. I Ideal for microcontrollers: native bitwise operations, procedural code, distinction between int and float, robust exceptions. I Lots of opportunities for optimisation (this may sound surprising, but Python is compiled). D.P. George (George Robotics Ltd) MicroPython on LEON 4/21 Why can't we use existing CPython? (or PyPy?) I Integer operations: Integer object (max 30 bits): 4 words (16 bytes) Preallocates 257+5=262 ints −! 4k RAM! Could ROM them, but that's still 4k ROM. And each integer outside the preallocated ones would be another 16 bytes. I Method calls: led.on(): creates a bound-method object, 5 words (20 bytes) led.intensity(1000) −! 36 bytes RAM! I For loops: require heap to allocate a range iterator.
    [Show full text]
  • Goless Documentation Release 0.6.0
    goless Documentation Release 0.6.0 Rob Galanakis July 11, 2014 Contents 1 Intro 3 2 Goroutines 5 3 Channels 7 4 The select function 9 5 Exception Handling 11 6 Examples 13 7 Benchmarks 15 8 Backends 17 9 Compatibility Details 19 9.1 PyPy................................................... 19 9.2 Python 2 (CPython)........................................... 19 9.3 Python 3 (CPython)........................................... 19 9.4 Stackless Python............................................. 20 10 goless and the GIL 21 11 References 23 12 Contributing 25 13 Miscellany 27 14 Indices and tables 29 i ii goless Documentation, Release 0.6.0 • Intro • Goroutines • Channels • The select function • Exception Handling • Examples • Benchmarks • Backends • Compatibility Details • goless and the GIL • References • Contributing • Miscellany • Indices and tables Contents 1 goless Documentation, Release 0.6.0 2 Contents CHAPTER 1 Intro The goless library provides Go programming language semantics built on top of gevent, PyPy, or Stackless Python. For an example of what goless can do, here is the Go program at https://gobyexample.com/select reimplemented with goless: c1= goless.chan() c2= goless.chan() def func1(): time.sleep(1) c1.send(’one’) goless.go(func1) def func2(): time.sleep(2) c2.send(’two’) goless.go(func2) for i in range(2): case, val= goless.select([goless.rcase(c1), goless.rcase(c2)]) print(val) It is surely a testament to Go’s style that it isn’t much less Python code than Go code, but I quite like this. Don’t you? 3 goless Documentation, Release 0.6.0 4 Chapter 1. Intro CHAPTER 2 Goroutines The goless.go() function mimics Go’s goroutines by, unsurprisingly, running the routine in a tasklet/greenlet.
    [Show full text]
  • Google Picasa Eingestellt: Die Besten Alternativen Zur Fotoverwaltung
    Kein Support mehr ab Mitte März 2016 Google Picasa eingestellt: Die besten Alternativen zur Fotoverwaltung von Sebastian Kolar, Rainer Schuldt – COMPUTER-BILD 10.03.2016, 12:29 Uhr Ein Stück Software-Geschichte verschwindet von der Bildfläche: Google entwickelt Picasa nicht mehr weiter. Die Gelegenheit ist günstig, sich nach Alternativen umzuse- hen – COMPUTER BILD stellt vielfältigen Ersatz vor, der noch Updates erhält. Eingestampft: Google hegt kein Interesse mehr an Picasa. Schon 2012 verschwand der Linux-Ableger aus dem Netz, dasselbe Schicksal ereilt jetzt das Windows-Pendant. Wer in Masse fotografiert, kennt das Problem: Auf dem PC abgelegte Bilddateien gehen im Laufwerksdickicht unter. Versäumt man es, Dateien von vornherein geordnet auf der Platte zu speichern, artet späteres Auffinden zur Geduldsprobe aus. Mehr Freude an Bilddateien vergange- ner Tage verschaffte lange Zeit Picasa: Die Bildverwaltung präsentiert, sortiert und optimiert den Fotobestand von Hobbyknipsern. Mit der Weiterentwicklung des Programms ist nun Schluss: Die von Google im Juli 2004 übernommene Software stellt der Anbieter zum 15. März 2016 ein. Ge- nauer: Updates folgen keine mehr (siehe Blogpost). Anwender sind angehalten, zum Nachfolger Google Fotos zu wechseln. Da das nicht für jedermann infrage kommt, präsentiert die Redaktion Top-Alternativen zum kostenlosen Herunterladen. Reichlich Alternativen zum Nulltarif Obwohl sich Google Fotos als Ersatz für Picasa anbietet, unterscheiden sich beide Produkte grundlegend: Picasa ist ein PC-Werkzeug, während Google Fotos ausschließlich im Internet beziehungsweise Browser läuft – zumindest am PC. Für Mobilgeräte gibt es iOS- und Android-Apps. Legen Sie Wert auf eine lokal in- stallierte Anwendung mit Updates, werfen Sie einen Blick in die Zusammenstellung der Redaktion. Darin finden Sie Werkzeuge, die Ihre Bilder übersichtlich anzeigen, Farbfehler automatisch korrigieren und weit- reichende manuelle Bearbeitungen erlauben.
    [Show full text]
  • Fpm Documentation Release 1.7.0
    fpm Documentation Release 1.7.0 Jordan Sissel Sep 08, 2017 Contents 1 Backstory 3 2 The Solution - FPM 5 3 Things that should work 7 4 Table of Contents 9 4.1 What is FPM?..............................................9 4.2 Installation................................................ 10 4.3 Use Cases................................................. 11 4.4 Packages................................................. 13 4.5 Want to contribute? Or need help?.................................... 21 4.6 Release Notes and Change Log..................................... 22 i ii fpm Documentation, Release 1.7.0 Note: The documentation here is a work-in-progress. If you want to contribute new docs or report problems, I invite you to do so on the project issue tracker. The goal of fpm is to make it easy and quick to build packages such as rpms, debs, OSX packages, etc. fpm, as a project, exists with the following principles in mind: • If fpm is not helping you make packages easily, then there is a bug in fpm. • If you are having a bad time with fpm, then there is a bug in fpm. • If the documentation is confusing, then this is a bug in fpm. If there is a bug in fpm, then we can work together to fix it. If you wish to report a bug/problem/whatever, I welcome you to do on the project issue tracker. You can find out how to use fpm in the documentation. Contents 1 fpm Documentation, Release 1.7.0 2 Contents CHAPTER 1 Backstory Sometimes packaging is done wrong (because you can’t do it right for all situations), but small tweaks can fix it.
    [Show full text]
  • SQL Server Performance Tuning on Google Compute Engine
    SQL Server Performance Tuning on Google Compute Engine Erik Darling Brent Ozar Unlimited March 2017 Table of contents Introduction Measuring your existing SQL Server Trending backup size Projecting future space requirements Trending backup speed Bonus section: Backing up to NUL Trending DBCC CHECKDB Trending index maintenance Recap: your current vital stats Sizing your Google Compute Engine VM Choosing your instance type Compute Engine’s relationship between cores and memory Memory is more important in the cloud Choosing your CPU type Putting it all together: build, then experiment Measuring what SQL Server is waiting on An introduction to wait stats Getting more granular wait stats data Wait type reference list CPU Memory Disk Locks Latches Misc Always On Availability Groups waits Demo: Showing wait stats with a live workload About the database: orders About the workload Measuring SQL Server with sp_BlitzFirst Baseline #1: Waiting on PAGEIOLATCH, CXPACKET, SOS_SCHEDULER_YIELD Mitigation #1: Fixing PAGEIOLATCH, SOS_SCHEDULER_YIELD Configuring SQL Server to use the increased power TempDB Moving TempDB Max server memory 1 CPU Baseline #2: PAGEIOLATCH gone, SOS_SCHEDULER_YIELD still here Mitigation #2: Adding cores for SOS_SCHEDULER_YIELD waits Baseline #3: High CPU, and now LCK* waits Mitigation #3: Fixing LCK* waits with optimistic isolation levels Batch requests per second 2 Introduction This whitepaper discusses how to create a SQL server in Compute Engine and then use performance metrics to optimize its performance. This paper is intended for database administrators, Windows admins, or developers planning to build your first SQL Servers in Google Compute Engine. In this white paper, you’ll learn how to do the following: ● Measure your current SQL Server using data already have.
    [Show full text]
  • Setting up Your Environment
    APPENDIX A Setting Up Your Environment Choosing the correct tools to work with asyncio is a non-trivial choice, since it can significantly impact the availability and performance of asyncio. In this appendix, we discuss the interpreter and the packaging options that influence your asyncio experience. The Interpreter Depending on the API version of the interpreter, the syntax of declaring coroutines change and the suggestions considering API usage change. (Passing the loop parameter is considered deprecated for APIs newer than 3.6, instantiating your own loop should happen only in rare circumstances in Python 3.7, etc.) Availability Python interpreters adhere to the standard in varying degrees. This is because they are implementations/manifestations of the Python language specification, which is managed by the PSF. At the time of this writing, three relevant interpreters support at least parts of asyncio out of the box: CPython, MicroPython, and PyPy. © Mohamed Mustapha Tahrioui 2019 293 M. M. Tahrioui, asyncio Recipes, https://doi.org/10.1007/978-1-4842-4401-2 APPENDIX A SeTTinG Up YouR EnViROnMenT Since we are ideally interested in a complete or semi-complete implementation of asyncio, our choice is limited to CPython and PyPy. Both of these products have a great community. Since we are ideally using a lot powerful stdlib features, it is inevitable to pose the question of implementation completeness of a given interpreter with respect to the Python specification. The CPython interpreter is the reference implementation of the language specification and hence it adheres to the largest set of features in the language specification. At the point of this writing, CPython was targeting API version 3.7.
    [Show full text]
  • Optimizing and Evaluating Transient Gradual Typing
    Optimizing and Evaluating Transient Gradual Typing Michael M. Vitousek Jeremy G. Siek Avik Chaudhuri Indiana University, USA Indiana University, USA Facebook Inc., USA [email protected] [email protected] [email protected] Abstract 1 Introduction Gradual typing enables programmers to combine static and Gradual typing enables programmers to gradually evolve dynamic typing in the same language. However, ensuring their programs from the dynamic typing, which allows flex- sound interaction between the static and dynamic parts can ibility, to static typing, providing security [Siek and Taha incur runtime cost. In this paper, we analyze the perfor- 2006; Tobin-Hochstadt and Felleisen 2006]. Over the last mance of the transient design for gradual typing in Retic- decade, gradual typing has been of great interest to both ulated Python, a gradually typed variant of Python. This the research community [Ahmed et al. 2011; Allende et al. approach inserts lightweight checks throughout a program 2013a; Rastogi et al. 2012; Ren et al. 2013; Siek et al. 2015b; rather than installing proxies on higher order values. We Swamy et al. 2014; Takikawa et al. 2012], and to industry, show that, when using CPython as a host, performance de- which has introduced several languages with elements of creases as programs evolve from dynamic to static types, up gradual typing, such as TypeScript [Microsoft 2012], Flow to a 6× slowdown compared to equivalent Python programs. [Facebook 2014], and Dart [Google 2011]. Many existing To reduce this overhead, we design a static analysis and gradually typed languages operate by translating a “surface optimization that removes redundant runtime checks, em- language” program (i.e.
    [Show full text]
  • Open Data User Guide.Pdf
    PARTICIPANT’S GUIDE Virtual Machine Connection Details Hostname: hackwe1.cs.uwindsor.ca Operating System: Debian 6.0 (“Squeeze”) IP Address: 137.207.82.181 Middleware: Node.js, Perl, PHP, Python DBMS: MySQL, PostgreSQL Connection Type: SSH Web Server: Apache 2.2 UserID: root Available Text Editors: nano, vi Password: Nekhiav3 UserID: hackwe Feel free to install additional packages or tools. Password: Imusyeg6 Google Maps API Important Paths and Links Follow this quick tutorial to get started Home Directory https://developers.google.com/maps/documentation/javascript/tutorial /home/hackwe The most common objects you will use are LatLng objects which store a lati- tude and longitude, and Marker objects which place a point on a Map object APT Package Management Tool help.ubuntu.com/community/AptGet/Howto LatLng Object developers.google.com/maps/documentation/javascript/reference#LatLng City of Windsor Open Data Catalogue Marker Object www.citywindsor.ca/opendata/Pages/Open-Data- developers.google.com/maps/documentation/javascript/reference#Marker Catalogue.aspx Map Object Windsor Hackforge developers.google.com/maps/documentation/javascript/reference#Map hackf.org WeTech Alliance wetech-alliance.com XKCD xkcd.com PARTICIPANT’S GUIDE Working with Geospatial (SHP) Data in Linux Node.js Python To manipulate shape files in Python 2.x, you’ll need the pyshp package. These Required Libraries instructions will quickly outline how to install and use this package to get GIS data out of *.shp files. node-shp: Github - https://github.com/yuletide/node-shp Installation npm - https://npmjs.org/package/shp To install pyshp you first must have setuptools installed in your python site- packages.
    [Show full text]