How to read a chunk of lines from a file in Python

This article shows a Python generator that lets you read lines from a file, splitting it up in chucks, or blocks, to let you easily parallelize a program to analyze a very large file, without having to split that file in separate smaller files first.

Posted at 17:02 on 2013/04/13 | leave a comment | Filed Under: Multiprocessing, Python | read on

Looking for squarefree numbers

A friend proposed an interesting problem the other day: to find out how many numbers are there below N with at most one of each prime as a factor? These numbers are called square-free numbers, because they are not divisible by any square number. If a number is divisible by any larger power of some prime […]

Posted at 02:31 on 2013/02/23 | leave a comment | Filed Under: Backtracking, Number Theory, Prolog, Python | read on

About

I’m Nic, and this blog is my little “programming tricks” notebook. Whenever I see a cool piece of code I find interesting or useful I post it here, with theoretical remarks when appropriate. May post opinion pieces about technology too sometimes. — Nicolau Werneck <nwerneck@gmail.com>


Follow

Get every new post delivered to your Inbox.

Join 301 other followers