Welcome to Python Hacks! — Python Hacks - Scientific/financial Computing using Python - Iceweasel. The purpose is to develop and gather python based object oriented effective code to work with financial/scientific calculations like risk management, pricing and hedging.
Further the purpose to get or produce proper financial documentation for the scripts presented here. I have found that Python is a fantastic tool to develop financial tools. Some of the reasons for this are: Python is fully object orientedPython is strongly supported on numerical calculationsPython is easy to learn and have a clear syntaxPython is a worthy alternative to eg. Excel and Matlab doing Scientific calculationsPython can be almost as fast as eg. But allthough the financial system Front Arena use Python as a scripting language, there are very few homepages dedicated to financial calculations in Python. This is not just about Python, though. If you got comments to this site please send me a mail. Android-scripting. SL4A (Scripting Layer for Android) SL4A (Scripting Layer for Android) What is it?
From the project website Scripting Layer for Android (SL4A, formerly known as Android Scripting Environment or ASE) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface that makes it easy to get things done. If you own an Android powered phone and you're a programmer who likes to get things done, as opposed to a programmer who uses Java, then you'll definitely want to take a look at SL4A which will allow you to write scripts in the languages you already know to make your phone do what you want it to do.
In essence, it allows you to write scripts which have access to a subset of the Android functionality in a Real Language like Perl or Python. Perl support is not great currently (r25). Pycon2011 android programming-using_python. Multiprocessing Basics. The simplest way to spawn a second is to instantiate a Process object with a target function and call start() to let it begin working. import multiprocessing def worker(): """worker function""" print 'Worker' return if __name__ == '__main__': jobs = [] for i in range(5): p = multiprocessing.Process(target=worker) jobs.append(p) p.start() The output includes the word “Worker” printed five times, although it may not be entirely clean depending on the order of execution. $ python multiprocessing_simple.py Worker Worker Worker Worker Worker It usually more useful to be able to spawn a process with arguments to tell it what work to do.
Unlike with threading, to pass arguments to a multiprocessing Process the argument must be able to be serialized using pickle. Import multiprocessing def worker(num): """thread worker function""" print 'Worker:', num return if __name__ == '__main__': jobs = [] for i in range(5): p = multiprocessing.Process(target=worker, args=(i,)) jobs.append(p) p.start() Note. Efficient String Concatenation in Python. There is a Russian translation of this article, kindly provided by Artyom Scorecky (tonnzor).
An assessment of the performance of several methods Introduction Building long strings in the Python progamming language can sometimes result in very slow running code. In this article I investigate the computational performance of various string concatenation methods. In Python the string object is immutable - each time a string is assigned to a variable a new object is created in memory to represent the new value. What other methods are available and how does their performance compare?
For this comparison I required a test problem that calls for the construction of very long strings out of a large number of segments. The test case I used is to concatenate a series of integers from zero up to some large number. Six Methods These are the methods that I tested. Method 1: Naive appending def method1(): out_str = '' for num in xrange(loop_count): out_str += `num` return out_str.
Compressing-zlig-tzrfile-gzlib. Creating Daemons on Linux with Python. Keyboard Input. RegEx, re, Regular Expressions on Python. Processes and Pids in Python. Sort. Parallel Processing and Multiprocessing in Python. Debugging. Popular Python recipes.