EuroPython 2023

My takes from EuroPython 2023 in Prague Wednesday, 19th July, 2023 Kindnesses & Promises Personal experience of a community organiser Petr Viktorin. It felt a bit out of scope for me because Petr spoke about his path through life (we all have some) and emphasized the importance of community in Python. Community is not the most important thing for me in Python - the actual engineering part of Python is. From the members of the Python community (people who know each other and meet often at meetup) it seems that it is a necessity or essential progress, but I think that a lot of people can be part of Python, contribute to it and not be part of this community. ...

July 21, 2023 · 6 min

Snakepit contest at PyconSK 2018

I’ve attended amazing conference Pycon SK in Bratislava 2018. Part of the programme was a contest in a game snakepit (contests info). It was a nice game where contestants should write a behaviour of snake from the old game we all remember from childhood. Instead of paying attention to the conference talks the contest has absorbed me and I created quick and dirty idea of how should snake play the game. There was 11 contestants and my snake artimi0 end up at the third place! ...

March 11, 2018 · 2 min

Environment for efficient Python Programmng

In this article I would like to describe few tools I’m using everyday to be efficient Python programmer. There is multiple approaches how efficiently control your programming environment but I have converged to this set of tools. I’m looking from any tool that I’m using at work to be easy to learn i.e. having shortcuts always somewhere visible. controlable by shortcut that can be carved in my muscle memory. capable of fast perfomance tasks I’m doing quite often. So when we have my criteria stated let’s go to see what’s worth using and learning. ...

September 7, 2017 · 4 min

Winning application for Wood Coding Challenge

As some of Python community here in Czech Republic know there was held programming contest called Wood Coding Challenge organized by Wood & Company. The task was to create stock exchange using Python / C / C++ that runs on TCP sockets communicate by JSON messages and presents solid engineering abilities. You can find whole description of task at the website of the contest. This certainly had my attention and during two months I completed this challenge. I spent 50 hours of my evenings to code this up. I chose to write it in Python 3.5 using Asyncio as it was preferred library used by organizers. I learned a lot of Asyncio and it seems to be right tool to write asynchronous code. ...

July 19, 2016 · 3 min

Reloadable containers for Python

We often face an issue that our long running services need some parts to be reloadable without restart of such service. To achieve this I implemented simple abstract class that wraps any container we could use. You can find whole example at my Github page. from abc import ABC, abstractmethod import time class Reloadable(ABC): """ This class wraps a container and expose all its methods. It reloads its content after `reload_every_secs` from `path`. """ def __init__(self, path, reload_every_secs=60): self._path = path self._last_update = time.time() self._reload_every_secs = reload_every_secs self._initialize_data() self.reload() def reload(self): self._last_update = time.time() try: with open(self._path) as f: self._fill_data(f) except FileNotFoundError: self._initialize_data() @abstractmethod def _initialize_data(self): """Change container to initial state""" pass @abstractmethod def _fill_data(self, fp): """Fill data from file to container self._data""" pass def access(self): if time.time() - self._last_update > self._reload_every_secs: self.reload() def __getattr__(self, item): return getattr(self._data, item) def __len__(self): self.access() return self._data.__len__() def __getitem__(self, item): self.access() return self._data.__getitem__(item) def __setitem__(self, key, value): self.access() return self._data.__setitem__(key, value) def __delitem__(self, key): self.access() return self._data.__delitem__(key) def __iter__(self): self.access() return self._data.__iter__() def __reversed__(self): self.access() return self._data.__reversed__() def __contains__(self, item): self.access() return self._data.__contains__(item) def __str__(self): self.access() return self._data.__str__() As you can see this class just wraps not specified container and whenever we want to interact with it somehow we trigger function access(). To actually use it simply implement two methods _initialize_data and _fill_data and you will have your container reloaded every few second as you can specify. ...

July 12, 2016 · 2 min

Round-robin in Celery

Recently we faced an issue how to fairly distribute computational resources for our imaging service using Celery. The imaging service does some basic operations with image like resize. We chose Celery to distribute work among our workers. The service works with chunks of 1000 images that is processed in batch. We wanted to avoid situation where one large client uses all processors on a worker and other smaller clients would have to wait. To achieve this we needed to create special queue for each client. Celery worker then takes tasks from all queues in round robin fashion. The problem is that we do not know what clients will be using our service in future and thus we needed to add queues for them dynamically. To dynamically add new queue and more consumer for it call following method: ...

July 11, 2016 · 2 min

DNF to BDD in Haskell

This semester I have only two projects because it is my last semester at school (read my revaluation of study here). I am attending course called Functional and Logic Programming where we should learn this sort of programming languages. First project is written in Haskell and I chose to implement disjunctive normal form (DNF) to binary decision diagram (BDD) convertor. You can get the impression what this means from Formal Analysis and Verification lecture about BDDs on page 4 and further. As usual you can find the code at my github. It can print truth table of given formula, create ordered BDD and reduce it to ROBDD. Check the results with example formula ...

March 8, 2015 · 2 min

Pypete launch

I gladly present you my most recent piece of work in Python: Pypete - python performance tests. It is plugin to well known nosetests testing framework. If you run nosetests with my plugin turned on, it will timeit every test you have selected. You can save your results to file, compare it with older results and much more. As usual you can find my code at https://github.com/Artimi/pypete and install using pip. ...

October 3, 2014 · 2 min

Bob (Idiap) in Docker

Today I created my first Docker image. I’m really interested in Docker as a technology and I feel this should be one main route in virtualization field. The use of Docker is so easy and elegant that I wonder why it hasn’t existed for longer time. There still is big hype around Docker, especially now when they get $40M funding. With this Docker will become huge company. Anyway I wanted to create some docker image for practice and bumped into Bob, signal-processing and machine-learning toolbox that I was describing in one of my previous articles. I had a problem then with compatibilty. Bob runs only under Ubuntu, Mac OSX and Arch Linux. I am happy Fedora user and didn’t want to install Ubuntu. Luckily developers offered a solution for this situation: Virtual Machine. On the other hand it is VM in VirtualBox which is under Oracle and run demanding computation in VM with limited memory isn’t the kind of performance I was looking for. We fortunately got access to school server then, but the problem with other platforms still remains. ...

September 18, 2014 · 2 min

Sleeping Barber Implementation in Go

I wanted to learn (at least try) some new language, because I have feeling that I haven’t learnt anything in a long time. So I catched hype wave around Go. It is statically typed, with garbage collector, without OOP (I don’t like it anyway), by default statically linked language that was invented in Google. There is really nice and short tour that guided me in the beginings. Go’s killer feature is it’s concurrency model. It uses so called goroutines that are more lightweight than threads and channels that take care of communication between goroutines. ...

August 12, 2014 · 1 min