Notes from FOSDEM 2016

The Free and Open Source Developers’ European Meeting (FOSDEM) just concluded its 2016 edition in Brussels, Belgium. It was my first time attending this huge, fascinating, registration-free conference, and I really enjoyed the chance to become more familiar with the FOSS community and its ideals, and learn about some very cool projects and technologies. Here’s a quick summary of what I took away from FOSDEM, along with my notes from the talks I attended.

Some things I learned

See the notes below for more!

Disclaimer: The notes below represent my impressions of the content of these talks, jotted down as I listened. They may or may not be totally accurate, or precisely/adequately represent what the speakers said or think. If you want to get it from the horse’s mouth, follow the links to the FOSDEM schedule entry to find the abstract, slides, and/or other resources!


Day 1 - Saturday 30.01.2016


Python Tips, Tricks, and Dark Magic

Jordi Soucheiron


Design for All vs. Design for One and Adaptive User Interfaces

C. Strobbe (Stuttgart Media Uni/liberte0.org)

Github: cstrobbe

http://cstrobbe.github.io/AccessibilityResources/

GPII: universal preferences for accessibility settings gpii.net cloud4all.info

OpenSouceDesign.net

Freenote: #openSourceDeisgn

Github: OpenSourceDesigns


Exploring CPython

Stephane Wirbel

(matrixise on GitHub, Twitter)

Slides: https://speakerdeck.com/matrixise/exploring-our-python-interpreter

When you execute a Python command at the command line, the flow is:

How to get started contributing to Python:

Overview of directories (see slides)

Use ast to explore the structure of your python code:

import ast
tree = ast.parse('x = 2 + 2')

Use dis to explore bytecode (see Include/opcode.h for the codes)

Peepholer

Interpreter: everything is in Python/ceval.c, especially in the funciton PyEval_EvalFrameEx (huge switch statement that Allison Kaptur was talking about?)


Python Tricks from Mercurial

Pierre-Yves David

Imports

In Python, everything is stored as dictionaries (not entirely true, but for simplicity we’ll say it is) When python looks for wally, it searches:

When Python looks for wally.hat , it searches:

So if you put an attribute lookup inside of a loop, e.g.

for x in range(1000000):
	obj.att.append(0)

This will be slow because python has to look up the attribute each time. So you should do something like:

a = obj.att = [] #WHAT'S THIS?
for x in range(1000000):
	a.append(0)

Similarly, you should reassign globals/builtins to local variables for faster lookup inside of a loop:

def do_stuff():
	lmax = max
	for x in range(1000000):
		#do something with lmax() instead of max()

Something about __contains__ …?

__slots__: When Python creates an object, it creates a dictionary to store the object’s properties. It doesn’t know how many properties there’ll be, so it allocates a bunch of space. If you’re going to create a bunch of small objects (only a few properties), and you know they won’t need other properties, you should use __slots__ to tell Python only to create a dictionary of the right size, and not to allocate unnecessary space for the dictionary

Garbage collection can be turned off in certain situations to save time

PyPy sped up hg log from 3x to 12x

CPython also has room for improvement

Things not to do:


Going beyond CPython: CFFI and PyPy

Armin Rego

Slides: https://fosdem.org/2016/schedule/event/cpython/attachments/slides/944/export/events/attachments/cpython/slides/944/slides.html

PyPy: http://pypy.org/ CFFI: http://cffi.readthedocs.org/

CFFI (C Foreign Function Interface): Basically lets you execute C code right from python

PyPy: Python interpreter in Python

CPython C API


FAT Python - static optimizer

Victor Stinner

(haypo on GitHub, @victorstinner on Twitter)

PDF of slides on FOSDEM site

http://faster-cpython.readthedocs.org/fat_python.html

Problem: everythin in Python is mutable, e.g. you can replace builtin functions, function code, global variables… if you optimize based on the assumption that e.g. builtins haven’t been replaced, the optimization “breaks” python syntax and won’t work for all applications

Solution: implement “guards” to check assumptions before attempting to optimize the code; if assumptions don’t hold, skip the optimization

CPython already has optimization via the Peephole optimizer, but this is in C and is very limited

Optimizing AST:

PEPs related to FAT:

PEP 509: dict version - Each dict (e.g. builtins) has a version identifier, such that when something is changed in the dictionary, the version changes. This allows you to check whether e.g. something has been replaced in builtins dict.

PEP 510: Specialize - Adds PyFunction_Specialize() C function, and modifies Python/ceval.c to decide whether to specialize the code or not (e.g. based on result of guard checks)

PEP 511: Transformer - This one is controversial, still under discussion and may change


Lua: The Language of the Web?

Paul Cuthbertson

@paulcuth

Starlight project: Lua to ES6 transpiler https://github.com/paulcuth/starlight

Project started when he saw cool features of ES6 and noticed similarities with Lua (?) e.g. generators, …, proxies, destructuring, multiple return values, block scoping

Starlight transpiles Lua to ES6 (need to also include Babel to run as ES5 in browsers)

Allows you to write scripts in Lua and even import JS into the Lua env

Has a DOM API (same as Moonshine)

But not all features of Lua can translate to ES6

Also: Sailor MVC framework (uses Starlight) http://sailorproject.org/index.lua


Lua for scripting OSX: Hammerspoon

http://www.hammerspoon.org/


Mail2Voice - Accessible email


Day 2 - Sunday 31.01.2016


coala Code Analyzer

http://coala-analyzer.org/


Continuous translation with Weblate

Michal Čihař

https://weblate.org/en/


“Some of my best friends are localizers” - tips for developers to help localizers

Dwayne Bailey

dwayne@translate.co.za

http://www.translate.org.za/10-things-localizers-would-like-developers-to-keep-in-mind/


Hacking on the Fairphone 2

Kees Jongenburger

Freenode: #fairphone http://forum.fairphone.com


Comparing Codes of Conduct to Copyleft Licenses

Sumana Harihareswara

Sumana’s notes

Questions:


Putting 8 Million People on the Map

Blake Girardot

Humanitarian OpenStreetMap Team (HOT)