473,769 Members | 5,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Python for programming algorithms

Hello.

I am new to Python. It seems a very interesting language to me. Its
simplicity is very attractive.

However, it is usually said that Python is not a compiled but
interpreted programming language —I mean, it is not like C, in that
sense.

I am working on my PhD Thesis, which is about Operations Research,
heuristic algorithms, etc., and I am considering the possibility of
programming all my algorithms in Python.

The usual alternative is C, but I like Python more.

The main drawbacks I see to using Python are these:

* As far as I understand, the fact that Python is not a compiled
language makes it slower than C, when performing huge amounts of
computations within an algorithm or program.

* I don't know how likely it is to find libraries in Python related to
my research field.

* I know Python is a "serious" and mature programming language, of
course. But I do not know if it is seen as "just funny" in a research
context. Is Python considered as a good programming language for
implementing Operations Research algorithms, such as heuristics and
other soft-computing algorithms?

Maybe this is not the right forum, but maybe you can give me some
hints or tips...

Thank you in advance.
Jun 27 '08
53 5255
On May 19, 5:46*pm, "bruno.desthuil li...@gmail.com "
<bruno.desthuil li...@gmail.com wrote:
On 19 mai, 17:53, Henrique Dante de Almeida <hda...@gmail.c omwrote:

(snip)
*Yes, I was actually referring to statically typed JIT-compiled
languages. Sorry about that, blame the beers that entered my digestive
system that night. :-P

for beer in beers:
* if beer.entered_he nrique_digestiv e_system_last_n ight:
* * beer.blame()

!-)
???

beers += [Beer.random()]
Jun 27 '08 #31
Henrique Dante de Almeida a écrit :
On May 19, 5:35 pm, "bruno.desthuil li...@gmail.com "
<bruno.desthuil li...@gmail.com wrote:
>> The situation would be simpler if there were good well-known toolkits
for optimization in python (like numpy for matrix operations), but
that's not the case.
There's at least Psyco (if you're willing and able to restrict
yourself from using some of the most dynamic parts of Python - which
might not be a problem here). One could also mention stuff like Pyrex
and Cython.

I meant toolkits for "optimizati on problems", not "code
optimization".
oops, sorry.
Jun 27 '08 #32
On Mon, 19 May 2008 08:53:11 -0700, Henrique Dante de Almeida wrote:
On May 19, 6:52Â*am, Bruno Desthuilliers <bruno.
42.desthuilli.. .@websiteburo.i nvalidwrote:
>Henrique Dante de Almeida a écrit :
On May 17, 7:32 pm, Vicent Giner <vgi...@gmail.c omwrote:
Hello.

(snip)
>However, it is usually said that Python is not a compiled but
interpreted programming language —I mean, it is not like C, in that
sense.

(snip)
Â*I guess that python is not a good language for that.
(snip)
Â*My opinion: choose compiled or byte compiled languages.

Slightly OT (ie : not talking about computation-heavy alorgithm being
better implemented in C then wrapped in Python - this seems quite
obvious) but just a couple facts:

1/ being interpreted or compiled (for whatever definition of these
terms) is not a property of a language, but a property of an
implementati on of a language.

2/ actually, all known Python implementations compile to byte-code.

Yes, I was actually referring to statically typed JIT-compiled
languages. Sorry about that, blame the beers that entered my digestive
system that night. :-P
[beer.blame() for beer in beers]

if len(beers) 2:
news_reader.sto p_working()

:-)
Jun 27 '08 #33
On Mon, 19 May 2008 11:07:06 -0700, Vicent Giner wrote:
[...]
>
By the way, is it possible (and easy) to call a C function from a Python
program??
Yes.

http://groups.google.com/group/comp....47913a265c348a

-- Ivan
Jun 27 '08 #34
Vicent Giner wrote:
The usual answer is that development time is more important than running time.
This depends. Run time is not important until you are asked to scale to
millions or billions of users or computations or large data sets. I've
seen this first hand. Getting results back the same day or sooner may be
important. In cases such as this, I use C or C++... nothing else will
do. Nothing else is as fast. Although I always keep a py version around
for testing and for smaller tasks. Don't get me wrong, I love Python,
but there are times when nothing, but pure, hard speed will do.
Jun 27 '08 #35
Roel Schroeven <rs************ ****@fastmail.f mwrote:
C OTOH was designed to be compiled to assembly code (or directly to
machine code) and as a result there are no (or virtually) no
implementations that interpret C or compile it to bytecode.
Have you considered Microsoft's C/C++ compiler targetted at .Net. That
compiles to a bytecode known as MSIL which is then interpreted and/or JIT
compiled to machine code.
I love Python, but IMHO it's a bit silly to maintain that the fact that
Python compiles to byte code instead of assembly code/machine code is
purely a matter of implementation; on the contrary, I believe it's a
result of its design. I also think that there's a large difference
between byte code and machine code (in Python's case; I haven't looked
at other languages), and that it's a bit silly to try to trivialize that
difference.
And then there's IronPython which is targetted at .Net. That compiles to a
bytecode known as MSIL which is then interpreted and/or JIT compiled to
machine code.

--
Duncan Booth http://kupuguy.blogspot.com
Jun 27 '08 #36
brad <by*******@gmai l.comwrites:
>Vicent Giner wrote:
>The usual answer is that development time is more important than
running time.

This depends. Run time is not important until you are asked to scale
to millions or billions of users or computations or large data
sets. I've seen this first hand. Getting results back the same day or
sooner may be important. In cases such as this, I use C or
C++... nothing else will do. Nothing else is as fast. Although I
always keep a py version around for testing and for smaller
tasks. Don't get me wrong, I love Python, but there are times when
nothing, but pure, hard speed will do.
Sure. Be careful not to overdose on it though.

--
Arnaud
Jun 27 '08 #37
On May 19, 8:07 pm, Vicent Giner <vgi...@gmail.c omwrote:
By the way, is it possible (and easy) to call a C function from a
Python program??
Yes it is. You can e.g. use ctypes for that.
Jun 27 '08 #38
On May 19, 10:42 pm, "bruno.desthuil li...@gmail.com "
<bruno.desthuil li...@gmail.com wrote:
Well... They do - they are called 'C compilers' !-) As Roel Schroven
mentioned - and he is at least partially right on this point - C has
been designed to make optimizing C compiler not to hairy to write.
C has proven very difficult to optimize, particularly because pointer
aliasing prevents efficient register allocation.

Fortran was designed with ease of optimization in mind. Not many years
ago, it was not uncommon for Fortran code to run twice as fast as
equivalent C. C compilers have recently closed on on the gap by
becoming extremely good at what they do. But that is not because C is
easy to optimize. On the contrary.

For serious number crunshing, there is nothing that compares to
Fortran, even today. f2py makes it easy to call Fortran subroutines
from Python.

Jun 27 '08 #39
On 2008-05-20, Ivan Illarionov <iv************ *@gmail.comwrot e:
On Mon, 19 May 2008 11:07:06 -0700, Vicent Giner wrote:
[...]
>>
By the way, is it possible (and easy) to call a C function from a Python
program??

Yes.

http://groups.google.com/group/comp....47913a265c348a
Even easier:

http://docs.python.org/lib/module-ctypes.html

--
Grant Edwards grante Yow! I'd like some JUNK
at FOOD ... and then I want to
visi.com be ALONE --
Jun 27 '08 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
3986
by: Joe Cheng | last post by:
I'm curious about something... many Artima.com members who have a Java background and learned Python have come to the conclusion that Java and Python are highly complimentary languages. They would never consider filling the place Java has in their toolbox with Python, but recognize there are many tasks where it really pays to add Python to the mix. I want to ask you hard-core c.l.p Pythonistas: Do you use Python for everything? (and...
226
12678
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
68
5885
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
20
2162
by: xeys_00 | last post by:
I posted a article earlier pertaining programming for my boss. Now I am gonna ask a question about programming for myself. I just finished my first C++ Class. Next semester is a class on encryption(and it's probably gonna be a math class too). And finally back in programming in the fall with C++ and Java 1. The C++ will cover pointers, and linked lists, sorting algorithms, etc... I run linux and OS X. I have read in the old days that C was...
13
5907
by: abhinav | last post by:
Hi guys.I have to implement a topical crawler as a part of my project.What language should i implement C or Python?Python though has fast development cycle but my concern is speed also.I want to strke a balance between development speed and crawler speed.Since Python is an interpreted language it is rather slow.The crawler which will be working on huge set of pages should be as fast as possible.One possible implementation would be...
27
2059
by: hacker1017 | last post by:
im just asking out of curiosity.
2
3683
by: Xiao Jianfeng | last post by:
Hi all, I am looking for a genetic algorithms package for Python. I have googled the web before posting and found some links. The link of pygene(http://www.freenet.org.nz/python/pygene) cannot be opened. I also tried the recipe on ASPN, but it is too simple for my application, and the ga model in SciPy, which is in testing in the "sandbox".
11
3778
by: efrat | last post by:
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure appreciate it: 1. What exactly is a Python list? If one writes a, then is the complexity Theta(n)? If this is O(1), then why was the name "list" chosen? If this is indeed Theta(n), then what alternative should be used? (array does not seem suited for...
18
7436
by: Jens | last post by:
I'm starting a project in data mining, and I'm considering Python and Java as possible platforms. I'm conserned by performance. Most benchmarks report that Java is about 10-15 times faster than Python, and my own experiments confirms this. I could imagine this to become a problem for very large datasets. How good is the integration with MySQL in Python?
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.