Notes taken during a Performance talk given at PyConUK.

function calls

c method instead
cython instead

Use operators



list comprehension is quicker than for loop over an emnumerator

What is op?

xrange vs range
– no wasted memory

NB: In python3 renamed range


Or use a c extension



l.sort vs sorted() – any iterator

Key based:

look up operator -> operator.itemgetter

Can use on object attribute


“”.join([a, b, c]) faster but less readable

% method not that fast an ugly – don’t use

Int keys are faster than string keys

interned string keys – no garbage collection

sys.intern – P3

Variable look ups

Mentioned global variable trick

local var faster than global in general

Look up: Old style/new style classes??

Slot attributes ?? look up more just seemed to be attributes???

Don’t use exceptions as an often use case. => much faster say to use getattr than catch a valueexception

Try to rely on c methods

Profiling tools:
c profiler built into Python

cpython vs number – can make pythonrun as fast as C – suggestion

A Pinch of Salt by Scott Walton

Scott Walton gave a talk about how they use Salt, at their company Pebble.

Slides can be found here:

Salt is a remote config management tool, similar to: Ansible, Puppet, Chef. It seems from talks with others at PyConUK Ansible and Salt were being described more favourably than Puppet and Chef.  Either due to their complexity or through battle testing and reaching their limitations.

Salt terminology

  • Master
  • Minion
  • Grain – data on a minion – like an attribute, how much memory (-G)
  • Pillar – data about a set of a minion, e.g. stage of server
  • Matching – rules to identify minions
  • Modules – commands
  • State – end result

Pebble use Salt to manage a complex system, finance, web servers, databases, load balancing, managing various environments – test, stage, prod etc.

Their journey was via fabric

Implemented in Python

Zero MQ, encrypted secure connections are used

Used apt-get vs pip to install – as in his opinion, it included a flaky dependency

Can add watches for changes to take actions, e.g. if web server config file changes, restart the web server

Can use Jinga in config files pillar (and grain) are available in these templates

Salt can take fall back actions for common features, e.g. running git clone or git pull depending upon whether the repo exists.

– started using 2 years ago


– chef & puppet looked more complicated
– salt looked for familiar
– friendly community
– easy to get involved in the code
– can easily contribute back pull requests
– documentation has gotten better
– includes very simple state
– reference is very good
– e.g. ‘return as’ is not as well documented as yet

Easy to configure

can command Less files TBC
If not built in, can just run bash commands e.g. could run a Django migration

Trouble at t’LeedsDataMill: ~ Big Data meets Big Brass (Nicholas Tollervey & Simon Davy)

Trouble at t’LeedsDataMill: ~ Big Data meets Big Brass (Nicholas Tollervey & Simon Davy)

Leeds data mill – hackers of open data

Played with footfall data represented as music

Python created a Lilypod file –

=> 7am was a fav Tubor section

Much jokes of a Dubstep/D&B version – When’s the next album out – lol

PyPi (not that one): By Ben Nutall from the Raspberry PI Education team

Notes taken during a talk given by Ben Nutall at PyConUK.

Book: Learning Python with Raspberry Pi, Alex Bradbury and Ben Everard.

Book: Adventures in Raspberry Pi – Carrie Anne Philbin

Experience: open a rasp pi: have a desktop, can open idle

Hardware: Now 40 GPIO pins on B+, same price

Look at:


Add on camera available, 10MP??

Look at “import picamera”
– nice docs


Kids track to take photos wired button to board, took photos – based on a stock motion Lego scene

Another idea: Cat detector – also spray with water, then a video was sent to you tube ;)

Robotics – mini maker stuff -like a pi on wheels

Look at kick start for kit style projects

Free resources on their web site

Minecraft PI edition – limited installed by default

Energenie – remote switches for plug sockets can control via python/raspberry pi

sous-vide cooking – used to monitor temparture, turn off/on cooker  – He tried the steak – Yum!


bennuttall @ github


Pi Phone – is a proof of concept – need for proper open smart phone – not a Python project
Ans: can by the developer kit for the compute module for the R Pi

Also have a PiPad – a screen with a pi in it

*) What’s after B+

512M RAM
4 USB ports, etc
Continue developing the hardware
Just realised

Look at PiFi or WiPi <-