It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I recently have been considering switching to the Python programming language. Currently, Matlab is the language of choice in my department for rapid development and prototyping of code. It’s very good at this, but Mathworks (the company who produces Matlab) have been tinkering with the licencing terms, leading to hassles where none should exist.
I have found python+numpy+scipy+matplotlib+IPython+[random sci/numerical packages] to be almost a complete replacement for matlab. There are certainly some packages missing, so if there is a specialized set of tools that are available in matlab but not in python, this might be an issue, but otherwise, I haven't looked back.
I'll mention a couple of distinct advantages of python over matlab
True programming language instead of a hack of a language thrown over a numerical package (numpy came to python instead of the other way around). Managing large python projects is a complete joy vs matlab. How many different oop systems have been mangled into matlab?
Totally free and portable. I can use python on just about any machine without licensing issues. This is the biggest advantage from my perspective.
Wrapping other libraries in C,C++, Fortran is fairly straightforward using SWIG, Cython,f2py,etc vs the ugliness that is a mex file
Cython for accelerating slow code (although I find that numpy is nearly as fast if not faster than matlab)
mpi4py vs some other package that I have to buy from matlab to run parallel applications
Personally I use the Enthought Python Distribution for a lot of my work, because it packages everything and is free for individuals in academia. I've alternatively built python and all of its libraries and modules from scratch. Module management is perhaps the largest weakness in python, but there are some nice things to help out like virtualenv and pip
The choice comes down to cost. If you are happy paying for Matlab - especially if you use the toolboxes - you will likely find Python doesn't provide such an integrated package. Having a matrix as the basic data type makes Matlab an intuitive language for many mathematical tasks. Personally, I find the this coupled with the debugger invaluable.
Python, through NumPy, SciPy and the like do provide the same functionality. There will of course be a learning curve to overcome.
If you are performing general programming tasks, that are not particularly applied math solutions then Python is an extremely easy to use and adaptable language. It is also free - which may be a deciding factor.
If you're looking for a wholesale Matlab replacement, you may want to take a look at Python(x, y). It aims to provide a more cohesive experience, rather than leaving new users to trawl the internet themselves looking for the right components to use.
Another option is GNU Octave, which is essentially an open-source clone of MATLAB.
Python certainly is useable as a replacement for Matlab for many cases, by using NumPy, SciPy, and Matplotlib (see my development environment setup guide for how to install all these packages). However, there are some things that Matlab does better, such as providing libraries for interfacing with data collection hardware. So you will need to try Python and see if it meets your requirements.
Should you switch or not depends on what you think of Python. I myself love Python, and I know it is extremely effective for rapid prototyping. The syntax is clean and crisp, and very easy to learn.
To make your decision I recommend visiting the home page, Python.org, and having a look at the docs.
Just download scipy and give it a try.
Related
I would like to solve an integer linear programming problem in python for the first time. After searching online I was pointed to lp_solve but I can't see how to get the python bindings installed in ubuntu. I have also had gurobi and cplex recommended but they are no open source. Is there a nice and simple way to set up an integer linear programming problem and have it solved in python using only free software?
I'm attending course on linear programming at the moment, recommended module for programming assignments was cvxopt.
I've actually found that I like PuLP module much more.
It's really nice module, give it a try.
I'd recommend looking at SCIP, see http://scip.zib.de/ and the Python interface
http://code.google.com/p/python-zibopt/, just look at the ZIB licence first.
If Academic licence is an option, you can get Cplex, Gurobi, Xpress and some others as well. I think GLPK may be an option if really free is the only option.
IMO, SCIP is fantastic for advanced prototyping, but obviosly works fine for simpler things like just setting up the ILP and solving it. Observe that SCIP can be wired with the most popular commercial alternatives as well for better performance.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have been studying Python at work for a week now and it seems very interesting, I started using it in order to create Extra Search functions for Splunk.
My Question is, what else can you do with it?, is it only a Script Language?, if so what type of scripts can I create and use?
To what extent should I learn Python in order to begin writing usable scripts?
I can write a Shell Korn script to Query a MySql Database, Can I do the same with Python?
You can pretty much do anything with Python that you can do with ksh, only easier (shells have a lot of stuff built in but many scripts will "reach out" to helpers like grep, sed awk, and so forth, to do grunt work).
Python also comes with an insanely large library (just like Java and C#) and plenty of add-on modules, both of which also include database stuff.
You don't have to learn Python to be able to script successfully, there's a large array of solutions for this. But Python is a useful weapon to have in your arsenal.
Bottom, it's quite able to handle a huge number of tasks, including the specific one you mentioned.
Aloha!
The obnoxious answer is that Python like other languages are turing complete and you can write program in it. But that probably doesn't answer your question. ;-)
First however, a tip: Stop think in terms of scripting vs real programming languages. Python, just like Java, Perl, Ruby, LISP, Scala, Lua, Cloujure are just as much real programming languages as C, C++, Fortran etc. The main difference is what they are running on. C for example can run on "bare metal", that is basically be translated to sequences of instructions that can be executed by the native/real CPU. Python, Java etc relies on a virtual machine to execute their instructions. The VM is then run by the real CPU.
The VM costs some performance, but add things like portability, dynamic behaviour (introspection, duck typing etc) that make the language and systems written in it very efficent in ways it is harder to do (but not impossible - remember Turing completeness) in for example C.
With that in min (Python is a real programming language) you might not be surprised to learn that Python can be and is used for things like:
Network servers and network applications. Look at the great Twisted networking framework and look and beautiful applications like Trac.
Large scale, professional distributed version control. Mercurial (Hg) is written entirely in Python and is able to handle huge, active projects with developers on a global level.
Compilers, languages and virtual machines. There is actually a virtual machine able to run Python written in Python(!). The machine called Pypy use some of the dynamic functionality of the language to enhance the performance.
Pypy is really a groovy concept - having the machine you are running your code in a language that can be modified at runtime - basically rebuilding the "hardware" from your application to enhance the machine to at the whim of the application. (And yes, I'm aware that all LISP guys yawn at this point - nothing new but still very, very groovy)
There you have it, some IMHO good, everything but simplistic, non-professional applications. Now start reading up on Python.org about the advanced features of the language and amazing functionality readily available in the standard lib. Your programming life will thank you for it.
Good luck!
To answer your questions in order:
Everything.
No.
Any.
As much as possible.
Yes.
Start here
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is there any interest in developing Rpython (Restricted Python) from the PyPy project as a general purpose programming language? Perhaps it could be a fork from the PyPy project. Does such a project exist? Since the programs are compiled, one could simply contribute modules written in Rpython, and it could compete with other python implementations including CPython and PyPy.
I can't speak for everyone else, but I personally am extremely interested in using RPython as a general-purpose language. To answer some other people's questions:
Why? Because Cython is a pain to figure out how to use. If you don't put in a lot of tricky type declarations just right, you don't get any speedup. With RPython, it will run fast or it won't run at all.
Using PyPy offers a good speedup, but currently not nearly as much as RPython.
RPython might be a good way to get super-fast, somewhat Pythonic code. Here's an example to help you get started. I'm not aware of any large projects to do this, unfortunately.
Yes, there is already a project to use the translation tool chain of PyPy to create standalone executables and libraries using RPython. It is called RPythonic.
A general purpose RPython would not be a competitor for CPython and PyPy. It wouldn't even be a competitor for things like Cython.
Why? Because RPython is not Python!! RPython is merely a language which shares some syntax with Python; enough that a Python interpreter can execute RPython code, but you cannot take Python code and compile it as RPython.
The restrictions on Python that are added to enable RPython to be statically typed and compiled (indeed, to have static type inference) are so severe that they completely change the language. If you want to write an RPython program, you have to decide to do so up front and write it in RPython. You can't write a program in Python and then decide to compile it as RPython, and you can't even tweak a realistic Python program a bit to make it RPython. Normal Python code is nothing like normal RPython code; writing RPython is more similar to writing Java or C#.
So if you want to write general programs in Python but you want them to go faster, RPython has very little to offer you. That's the niche PyPy's Python interpreter is trying to fill.
If you want to write general programs in a lower level compiled language because you need your program to run faster than Python, then there are existing very mature languages and libraries for that, like Java or C#.
The reason to code in RPython would be to do something that is particularly made better by RPython. Like writing interpreters to which you can add garbage collectors and JIT compilers without having to write them by hand! Here RPython shines, and yes I would be very interested in a more polished and usable RPython interpreter-writing environment. But as a general purpose programming language for writing programs that don't particularly benefit from RPython's specialities, it would simply be a monstrous amount of work to get it to the point where it could compete with existing languages that already fill that role better. It barely even has a standard library now (because almost none of Python's extensive standard library is usable in RPython), for example.
From the looks of it, the restrictions are quite severe and on the whole it's a lot less to program in, I imagine. That's necessary for implementing PyPy, but generally if you want fast compiled code that can interact with Python, you'd use Cython (which is targeted at CPython extensions and supports pretty much all of Python seamlessly) or write code in one of the more common languages that can do this. And if you just want fast, compiled code... well, RPython may be more pleasant than e.g. C, but still, I don't see a significant advantage here (at least none that would warrant the effort to create a usable, stable language).
Why would I want to write directly in RPython?
It seems so much simpler to Python code and run PyPy.
Why would I want to write C code?
It seems so much simpler to write Python and have PyPy be implemented in C
Why would I want to write assembler code?
It seems so much simpler to write Python and have PyPy implemented in C and C implemented in Assembler.
I guess it really is turtles all the way down.
Why would I want to stop using the most convenient language and switch to a less convenient language?
What's the value in giving up a nice language?
I need a library to handle computational geometry in a project, especially boolean operations, but just about every feature is useful. The best library I can find for this is CGAL, but this is the sort of project I would hesitate to make without garbage collection.
What language/library pairs can you recommend? So far my best bet is importing CGAL into D. There is also a project for making Python bindings for CGAL, but it's very incomplete.
I would still recommend to proceed with Python and the existing Python binding. When you find it's incomplete, you'll also find that it is fairly easy to extend - Python's C API is designed so that integrating with external libraries is fairly easy (for experienced C programmers).
Perhaps you can look at Shapely for python
http://pypi.python.org/pypi/Shapely/
For Java I would use JTS
For .NET I would use SharpMap or .NETTopologySuite
The CGAL-bindings project provides bindings for CGAL using SWIG. The targeted languages, so far, are Java and Python. The CGAL-bindings project is open source, and supported/founded by two french companies.
JTS is also available in .NET via IKVM.
I've just found this and it seems very promising even if it seems a young project: https://pyrr.readthedocs.org/en/latest/index.html#
Pyrr is a Python mathematical library.
and it is based on numpy!
I'm porting some MATLAB functions to Scilab. The cool thing is that there is a conversion toolbox that make things very easy.
The problem is I did not find the counterpart to the syms function, and the symbolic toolbox in general. (I'd like a port of the Control System Toolbox too, amd I'm still searching for some functions I'd may need).
The only thing about symbolic toolbox I've found is this, but it was a little trcky and not so easy (actually I was not able to set up it correctly in 30 minutes, and I gave up for now. I'm going to try later), and it needs Maxima to be installed. Does anyone know anything about that?
Scilab is not exactly a must. The project aims to give a more free and open source alternative to MATLAB. I saw there is SymPy for Python, and I just could use it with SciPy, but I'd lost the conversion toolbox thing :\
That said, what should be better? Get SciLab and Maxima work together or move to Python & co.? This is the start of the project, so the earlier I choose this, the better.
See Bye MATLAB, hello Python, thanks Sage for a first-hand experience of migrating from MATLAB to Python.
Not to discourage your project, but if you just want a free and open source alternative to MATLAB, have you looked at the Octave project? Contributing there might be more productive than building your own MATLAB alternative.
If your project requires the functionality of MATLAB's Symbolic then take a look at
http://wiki.octave.org/wiki.pl?CategorySymbolic
From my quick Google search I didn't find anything comparable to MATLAB's Simulink.
Also, Python and SciPy do have most of the functionality of MATLAB, and I guess Scilab's conversion utility would be useful in porting your own M-Files into Scilab code.
Your question seems to imply you want to port over MATLAB Toolboxes
The only thing about symbolic toolbox I've found is this...
I hope I am just misinterpreting you. If you are then there might be licensing issues if you were to distribute your system because the MATLAB Toolbox. Just a thought. But perhaps you wish to port your MATLAB code to, so that it doesn't not have the MATLAB dependency.
Update
For Control System functionality Octave, I just found that Octave does have a toolbox, see:
Octave Control Systems Toolbox
Which has some of the functionality of Simulink, but it doesn't seem to have the graphical interface for building block diagrams.