Trie in Python

A post about Haskell vs. Python readability came onto my radar the other day. It compares two implementations of a trie structure, and after looking upon the Python version I wanted to make my own attempt. I didn't make it to necessarily compare or "battle" against the other solutions, it's ...

nfp

So what happened was, I fed up manually uploading pictures I export from Darktable to my Flickr photo stream using the browser's file picker. So I decided to do something about it. The initial idea was to craft a FUSE file system which would automatically upload new files, but this ...

Dicts are now ordered, get used to it

05.02.2020

Python

There were several moments over the last few weeks when I heard people discuss differences between Python lists and dicts and one of the first ones mentioned was that lists are ordered and dicts are not. Well, not anymore. Quoting the docs referenced above: Changed in version 3.7: Dictionary order ...

Python stdlib gems: collections.Counter

09.03.2019

Python

Here's a toy problem. Given a corpus of phone numbers for different countries determine a most prevalent display format in each country and use it to re-format an arbitrary phone number for its country. For example, if most US numbers in our data corpus are written like xxx-xxx-xxxx then the ...

ijson 2.0

Yesterday I released version 2.0 of the streaming JSON parser ijson. It mostly includes bug fixes accumulated over the last year and the only reason to change the major part of the version number was that import ijson doesn't do any discovery magic anymore. Import Previously, when you did import ...

Refactoring discovery protocol

It's been a while since my last update on the python3-openid refactoring. Though I still work on it pretty actively, I totally failed at documenting the process as I planned in the beginning. So I came up with a new plan. New plan First of all, I admit to gravely ...

Carpet testing

Carpet bombing is a "large aerial bombing done in a progressive manner to inflict damage in every part of a selected area of land." Similarly, carpet testing is done by progressively tossing random data samples at your code without regard for its internal structure, hoping that sufficient amount of data ...

Dissecting fetchers

This is the first installment of my diaries on refactoring python3-openid. The post is turning out pretty big so may be I should try doing them more often. Warm-up I started with fixing failing tests, because you can't do refactoring without tests. The root cause of errors was somewhere inside ...

OpenID library for Python 3

Apparently, there is no obvious choice for an OpenID library in Python 3. In Python 2 there's python-openid which — despite being an ugly over-engineered mess of a code — works and conforms to the spec. Unfortunately, the same can't be said about its independent port to Python3 python3-openid, which ...

Форум переехал

30.06.2014

Python

Ура! Мой старый форум обрёл сегодня новое место. И нового хозяина, который, правда, не хочет публичного внимания, поэтому попросил его не называть. В любом случае, спасибо ему большое! http://pytalk.ru/forum/ Прошу любить и жаловать! (Да, штамп. Ну и что?) Несмотря на мой пессимистичный прогноз, переезд случился как нельзя более просто. Я ...

Memory is slow

Did you know that memory is slow compared to CPU? I kinda knew too but recently I've got a revelation from two unrelated sources about how it affects design of programming languages. I also learned about a new thing called "value/reference type dichotomy". I've stumbled upon this term while reading ...

PyCon Russia 2014

18.05.2014

Python

К вящему моему удивлению, мой бложик всё ещё читают люди, которые связывают свою профессиональную деятельность с Питоном. Так вот, друзья, специально для вас хочу напомнить, что через 2 недели начинается второй российский PyCon. Там опять будут умные люди, и как показывает мой опыт, на питоньих конференциях можно очень запросто пообщаться ...

Про форум (и русскоязычное питонье сообщество)

11.05.2014

Python

Как я упомянул в прошлом посте, я собираюсь закрыть форум, работающий на этом сайте с 2005 года. Несмотря на то, что он когда-то был довольно популярной площадкой для общения русскоязычных джангистов и питонистов, причин для его закрытия набралось достаточно. Состояние дел Пик популярности пришёлся на 2010 год, когда в месяц ...

Glyph Lefkowitz on threads

I value very much the ability to put complex concepts into words in a systematic manner. And I thrive to do the same (at least, I did try when I was blogging actively). So now I'm a big fan of Glyph who laid out everything that is problematic about threads: ...

Рефакторинг одного скринкаста

16.01.2013

Python

В прошлом ревью одного скринкаста я написал такой "P.S.": А вообще, чисто архитектурно, никаких классов тут конечно не нужно. Всё в единственном экземпляре и вызывается ровно один раз, поэтому классы только лишними self везде мешаются. И после этого, конечно, не выдержал и решил действительно порефакторить этот код, чтобы всё было ...

Ревью одного скринкаста

13.01.2013

Python

Бобук вчера попросил комментариев на свой небольшой скринкаст. Я попробовал, было, делать это прямо в Твиттере, но быстро осознал кривость затеи. Переделываю по-правильному, как нормальный ревью кода. Как в любом ревью, комментарии не претендуют на абсолютную истину и не являются оценкой автора кода — это просто взгляд другого программиста. Полный ...

ijson 1.0

25.10.2012

Python

I've finally scraped some time to finish and release a new version of ijson — 1.0. New stuff: support for YAJL 2 pure Python parser compatibility with Python 2 and Python 3 Parsing improvements On this I have already posted in details not that long ago. To summarize, ijson now ...

ijson on PyPy, Episode 3: New parsing

06.09.2012

Python

It's a funny thing when after neglecting your project for a year you get a question on whether it's orphaned and then suddenly you find yourself hacking on it for few days straight… Knowing that your work is needed and appreciated is the greatest motivator! Anyway… The news I wanted ...

When to use decorators in Python

09.07.2012

Python

The @decorator syntax in Python is easy to abuse. After all, it's simply a syntactic sugar for: obj = decorator(obj) The obj must be a function or a class but Python doesn't care about the output value that is then assigned to the same name. It may be, quite literally, ...

virtualenv: solved

25.05.2012

Python

My problem with virtualenv is solved. Great thanks to Malcolm Tredinnick for taking the time to understand it and pushing me into the right direction. As I said in the previous post, I didn't really need the isolation feature of virtualenv with my single-user, single-codebase site. What I really needed ...