Dissecting Python List allocator (CPython)

List is one of the most frequently used data structure in Python applications. The code for Python list object allocator is present in Python-2.7.5/Objects/listobject.c. Python allocates list objects in heap and uses underlying malloc based APIs. List is a container of Python object references. In plain C terminology. it is a dynamic array of pointers. [...]


How to limit heap size of a Python process on Linux?

Python allows customization to resource allocation for a Python VM instance. http://docs.python.org/2/library/resource.html import resource resource.setrlimit(resource.RLIMIT_AS, (megs * 1048576L, -1L))

Openstack swift: EADDRNOTAVAIL error

Problem swift-bench keeps EADDRNOTAVAIL error with a highly concurrency setting and multiple swift-bench clients. Setup Ubuntu 13, Swift single machine installation (refer SAIO), swift-client runs local with no-proxy mode. Solution EADDRNOTAVAIL stands for either unavailability of ephemeral ports and a known kernel bug. Check your range of ports: $cat /proc/sys/net/ipv4/ip_local_port_range swift-bench in no-proxy mode uses [...]

Best Python memcache client: Python-memcached v/s Pylibmc

Recently, I tried to access memcached server on local and remote setup in a Python application. I am sharing my experience with two of most popular clients. Python-memcached The first choice was a pure  Python solution to access memcached, that is python-memcached. It is a simple to install, understand and use solution. It do not [...]

Python Internals: Understanding Python data model (I)

Python sees everything as object. Every object has an identity, value and a type. Object identity and type are invariable. Object type determines if value is mutable or otherwise. Lifetime of object is based on reference count mechanism. Object Container Object containers are: list, dictionary, tuple, set. Containers keep reference (object identity) to objects. Mutability [...]

Pylucene- Part III: Hightlighting in Search

The search result can be customized to highlight the phrases that contain the requested keyword. The following code uses "Highlighter" class from Pylucene. We emit result in HTML formatted syntax. from lucene import \             QueryParser, IndexSearcher, IndexReader, StandardAnalyzer, \         TermPositionVector, SimpleFSDirectory, File, SimpleSpanFragmenter, Highlighter, \     QueryScorer, StringReader, SimpleHTMLFormatter, \             VERSION, initVM, [...]