public marks

PUBLIC MARKS from pvergain with tag bibliotheques

August 2007

Python instead of Matlab for plotting?

A few years ago I «fell in love» with Python , which is a dynamically typed interactive, object oriented scripting language. With a few extensions I found it very suitable for efficient visualization and problem solving in Scientific computing. So can it replace Matlab? For me its pretty close! For you? It depends on your needs, but have a look! Why I use Python * Python is a small, high level scripting language that sits on top of a efficient C library. Because of this, Python code is compact, and the resulting code can run at a speed close to C if the computationally intensive parts are done via library calls. * Short learning curve - I was almost instantly productive. * Python can be used interactively (like matlab), and documentation for most functions can be accessed via a built in help facility. * It is free (also in this regard) * The syntax invites you to write clean code. No ;'s at the end of lines, the block structure is described by indentation instead of Begin-End or {..}. Through the Numeric/numarray modules one gets powerful array syntax - inspired by languages such as Fortran 90, Matlab, Octave, Yorick etc. Python itself has also borrowed features from e.g. Lisp, with its interactivity and built in support for list manipulation. * Python has many other useful modules built in, one may for instance write a web server in just a few lines of code or work transparently with gzipped files (handy for analyzing large ascii data files) * Linking in and reusing Fortran subroutines is very easy using e.g. f2py mentioned below, or the Pyfort module found on www.python.org. Integration with C is of course even tighter since the most popular python is written in C. (yes. there is a java python...) * It is possible to work in single precision, which is sufficient for most scientific purposes. This makes it easier to work with large datasets/arrays using only half the memory compared to e.g. matlab. As my basic setup I use Python with the following extensions: Numpy: a.k.a. Numeric python, contain the advanced array syntax, as well as powerful and commonly used functions that can be applied to the multi dimensional arrays. Pygist: Gist is a very fast graphics library for 2D and 3D plots written directly for X11, but also ported to Mac and Windows. Gist is a part of the Yorick language. Pygist contain the Python bindings, read about it here. A recent version of Pygist can be found here. Pygist is currently also a part of a distribution of Python packages called Scipy, that can be found here. f2py: Makes connecting Fortran subroutines a breeze! Also a part of Scipy. A complete example: wrap this subroutine in a Python function returning "dist": [avle@tindved test]$ cat r1.f90 subroutine r1(x,y,n,dist) real x(n),y(n) !f2py intent(out) dist xl=0.0 ; yl=0.0 ; vp=0.0 do i=1,n xl=xl + x(i)**2 ; yl=yl + y(i)**2 vp=vp + x(i)*y(i) end do if(vp>=0.0)then dist = acos(sqrt(vp/(xl*yl))) else dist = 4*atan(1.0)-acos(sqrt(-vp/(xl*yl))) end if end subroutine r1 [avle@tindved test]$ ls r1.f90 [avle@tindved test]$ f2py -c -m r1 --fcompiler=g95 r1.f90 ..lots of output... [avle@tindved test]$ ls r1.f90 r1.so* [avle@tindved test]$ python2 Python 2.2.3 (#1, Feb 15 2005, 02:41:06) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Numeric as nx, r1 >>> a=nx.array((2.3,2.2)) ; b=nx.array((3.2,2.1)) >>> r1.r1(a,b) 1.2827057838439941 >>>

pynetfilter_conntrack - INL software - Trac

by 1 other
pynetfilter_conntrack is a Python binding of libnetfilter_conntrack. The binding is the file pynetfilter_conntrack.py and you have also a clone of conntrack program: conntrack.py. See also pyctd project. What's this? ¶ This python library is based on libnetfilter_conntrack, which lets you manipulate conntrack objects. In other words, pynetfilter_conntrack lets you deal with Netfilter's stateful inspection objects from the Python world. Practically, for the administrator, this means you can now easily close connections of your choice on your Linux [2.6] firewall. You can also receive informations about all connections (how many packets have gone through, how many bytes, etc.). You will even be able to create new objects in the Connection Tracking (this means that complex protocols such as FTP, P2P, etc. can have Python dealing with them rather than complex kernel modules).

Python Package Index : Home

by 2 others
The Python Packaging Index (the software formerly known as Cheeseshop) is now available at http://pypi.python.org/pypi The old addresses (www.python.org/pypi, and cheeseshop.python.org/pypi) will continue to work, either as aliases or using HTTP redirections. The software was renamed to its old name (PyPI - Python Package Index), as the Cheeseshop name was ever confusing people unfamiliar with British television comedy sketch (and puzzling even to people familiar with the sketch, as you *can* get packages from the package index). The Python Package Index is a repository of software for the Python programming language. There are currently 2609 packages here. You may:

July 2007

PARLEY

PARLEY is an API for writing Python programs that implement the Actor model of distributed systems, in which lightweight concurrent processes communicate through asynchronous message-passing. Actor systems typically are easier to write and debug than traditional concurrent programs that use locks and shared memory. PARLEY can run using either traditional native threads, greenlets (lightweight threads), or Stackless Python's tasklets. A program written using PARLEY can choose between these models by changing a single line of code. Usage Messages in PARLEY can be arbitrary objects, but the standard message format is a 4-tuple: (tag, sender, args, kwargs). A typical way to handle such a message is to look up a function based on the tag; pass args and kwargs as parameters to the function (args being position parameters, and kwargs being keyword parameters); and to send the return value of the function as a message to the original sender. You can check out the latest version from Subversion using the following command: svn co http://artdent.homelinux.net/parley/trunk

May 2007

multitask - O2S Wiki

multitask allows [WWW] Python programs to use [WWW] generators (aka coroutines) to perform cooperative multitasking and asynchronous I/O. Applications written using multitask consist of a set of cooperating tasks that yield to a shared task manager whenever they perform a (potentially) blocking operation, such as I/O on a socket or getting data from a queue. The task manager temporarily suspends the task (allowing other tasks to run in the meantime) and then restarts it when the blocking operation is complete. Such an approach is suitable for applications that would otherwise have to use select() and/or multiple threads to achieve concurrency. multitask is [WWW] free software, distributed under the [WWW] MIT license.

February 2007

January 2007

pyblosxom openid server - snarfed.org

(via)
openid_server.py is a PyBlosxom plugin that implements OpenID 1.1. OpenID is a distributed authentication protocol, ie a single sign on platform, that uses URLs as identifiers. If you have a PyBlosxom site, this plugin allows you to login anywhere that accepts OpenID. This plugin also implements the Simple Registration Extension, which lets you optionally provide your name, email address, and other information automatically to sites that you log into with OpenID. In OpenID terminology, this plugin acts as an an Identifer and Identity Provider. It provides an endpoint URL, handles OpenID requests on that endpoint, allows associations, and authenticates the user with an HTML form. To use it, first download openid_server.py and openid_libs.zip and place them both in your plugins directory. (openid_libs.zip is a convenient, drop-in package of necessary libraries, provided by JanRain, Yadis, and others. If you don't trust me - and why should you? - feel free to build and install them yourself.)

About — OpenID Enabled

by 1 other (via)
The OpenID library with batteries included. Features: * Refined and easy-to-use API. * Extensive documentation. * Many storage implemetations including file-based, SQL, and memcached. * Simple examples to help you get started. * Licensed under the LGPL. The latest available version is 1.2.0. Contenu en relation * Browse the source code * Downloads * Online API Documentation Examples do work nicely! Posté par http://nb.myopenid.com/ le 05-04-2006 06:35 Install of library works: python setup.py install installs in /usr/lib/python2.3/site-packages/openid Examples Start consumer and server python consumer.py --port 8001 python server.py --port 8000 Remember to use files (consumer.py and server.py) in example-folder NOT in openid folder!

Libraries - OpenID Wiki

(via)
The following libraries are available to assist with the implementation of an OpenID Identity Server and Consumer. The libraries in this section are intended to help with handling all of the details specific to OpenID and leaving you to provide the glue to integrate it into your site.

December 2006

pyjamas

by 3 others (via)
Many people, when first finding out about Google Web Toolkit, wonder "why can't I use Python instead of Java?". pyjamas is designed to make that possible. And we're drawing heavily from Google's work. It's in its early stages but I invite anyone who is interested to join the mailing list and check out what's in the Subversion repository. You'll see py-gwt referenced. That's just because that's what I was calling it before a better name came along. jorjun came up with pyjamas. We're still working on backworking an acronym for it that I like :-)

MochiRegExp - JavaScript Regular Expression (RegExp) Explorer

by 1 other
This demo does "live" Regular Expression matching to help you toy with JavaScript Regular Expressions. It takes advantage of MochiKit's MochiKit.DOM to manipulate the display and MochiKit.Async to facilitate the "half a second" live updating.

MochiKit - A lightweight Javascript library

MochiKit is a highly documented and well tested, suite of JavaScript libraries that will help you get shit done, fast. We took all the good ideas we could find from our Python, Objective-C, etc. experience and adapted it to the crazy world of JavaScript. Reliable MochiKit has HUNDREDS of tests. We build real applications with this thing. So even though development can move fast, we make sure to get tests written. This also makes platform compatibility issues much easier to detect and resolve than the "guess and check" style of quality assurance seen in some of the other libraries out there. It's not broken. Documented You're unlikely to find any JavaScript code with better documentation than MochiKit. We make a point to maintain 100% documentation coverage for all of MochiKit at all times. You don't have to fumble around reading our source code or leafing through examples to find out how something works. Evolutionary MochiKit can adapt to anything you throw at it. It makes no assumptions about how your code needs to act, and it has hooks (by way of the the adapter registries) that makes sure that you can define your own comparisons, programmer representations, iterators, or DOM node coercion for any object in any way you wish. We'll gladly serve you all the Kool-Aid you want, but we're not going to make you drink any.