Programming Methods & Algorithms scripts - Top 4 Download

Programming Methods & Algorithms script downloads

z matrix

This module provides two classes that emulate one and two dimentional lists with fixed sizes but mutable internals. Their primary purpose is to be used as a building tool for classes that need storage structures that cannot change in size. ...
Python

Arrayterator

This class creates a buffered iterator for reading big arrays in small contiguous blocks. The class is useful for objects stored in the filesystem. It allows iteration over the object without reading everything in memory; instead, small blocks are read and iterated over. The class can be used with any object ...
Python

Length limited O 1 LRU Cache implementation

Length-limited O(1) LRU Cache implementation script is an implementation of a length-limited O(1ion scripue. ...
Python

Format number function

For many languages it is possible to use the locale module to format numbers. But there are at least three languages for which the locale.localeconv()['thousands_sep'] is empty: brazilian portuguese - 'pt_br', portuguese - 'pt' and spanish - 'es'. The first function, format_positive_integer() will return the passed integer number as a string ...
Python

New Tail Recursion Decorator

This tail recursion decorator can eliminate the tail calls for recursive functions. ...
Python

Lazy Traversal of Directed Graphs

The os.path.walk routine that ships with the python standard library is limited to traversing the file system tree. This script allows you to realize a generic traversal for arbitrary (directed) graphs with support for recursion limits. ...
Python

Weighted choice

This script uses fact that any probability distributions can be sampled by computing the cumulative distribution, drawing a random number from 0 to 1, and finding the x-value where that number is attained on the cumulative distribution. The searchsorted(..) function performs this search. This script return random samples of cumulative vector ...
Python

Group and partition

This script enables the group_by functionality like the similar function existing in Ruby on Rails. ...
Python

Python Octree Implementation

This script is a simple implementation of an octree data structure in python. Its use is primarily for fast collision or view frustrum culling in interactive 3d environments, but its possible uses are quite open-ended. It was originally written for use with the pyOgre 3d engine binding. The code makes use of ...
Python

A general solution of Eight Queens

This script is a general method to figuren out all solutions of eight queens. Certainly, it can also solve any number of queens. Each solution is a list, and each value of the list represents the column number, at the same time the index of this value represents it's row number. For instance, ...
Python

Computing permutations with duplicates

This script handles duplicate values in a list. It could easily be made a generator, and it does not require recursion. ...
Python

Call a Callback when a Tkinter Text is Modified

This script shows you how to make use of the virtual event that determines to call your own callback. Tkinter Text widget notices when it's modified. ...
Python

Tkinter moving geometry methods

A common way to create new compound widgets is to inherit Frame, create everything you need inside it and pack this base Frame on your application.This script is an alternative to this method, that sets geometry methods and options from a wiget to another. ...
Python

Number Format function

This function takes a number (integer or float) and returns a string with the integer portion grouped by thousands and the decimal portion rounded or padded to given number of decimal places. ...
Python

All k subsets from an n set

This script yields each subset of size k from a super set of size n. There are two methods. The first operates on sets of integers of the form range(n). The seconds operates on arbitrary sets or lists. ...
Python

Print Hook

This class gets all output directed to stdout (e.g by print statements) and stderr and redirects it to a user defined function. ...
Python

Allowing the Python profiler to profile C modules

This script lets you take into account time spent in C modules when profiling your Python code. Normally the profiler only profiles Python code, so finding out how much time is spent accessing a database, running encryption code, sleeping and so on is difficult. Profilewrap makes it easy to profile C ...
Python

Shed Skin

Shed Skin is an experimental Python-to-C compiler. It can convert pure, but implicitly statically typed Python programs into optimized C code. Currently, these programs cannot freely use the Python standard library. ...
Python

Ensuring a name definition in a module namespace

This script ensures that a name exists in a target namespace. If it does not, make it available in the target namespace using the given definition. The target should be a namespace dictionary (presumably for a module, see the discussion below otherwise). The default target is __builtins__ (specificially, __builtins__.__dict__). ...
Python

Read write object for pkg config files

The PkgConfig class is useful by itself. It allows reading and writing of pkg-config files. This file, when executed, will read a .pc file and print the result of processing. The result will be functionally equivalent, but not identical. Re-running on its own output should produce identical results. ...
Python