473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

OCAMl a more natural extension language for python?

After reading about extending python with C/Fortran in the excellent Python
Scripting for Computational Science book by Hans Langtangen, I'm wondering
whether there's not a more pythonic way of extending python. And frankly I
think there is: OCAML

Fortunately there is already a project up and running allowing you to extend
python with OCAMl: http://pycaml.sourceforge.net/

Since I haven't got actual experience programming CAML I'd like to speculate
that OCAML would be a very pythonic way of extending python: its
open-source, object oriented, as fast as C, and ! garbage collecting!

Would making an effort integrating python & CAML not be very worthwhile?
I think an effort such as Joe Strouts python2c would be more relevant to a
language as CAMl since its conceptually more closer to python (how could you
automate programming memory allocation for instance)

So my question is: wouldn't there be some serious synergy in bringing python
& CAML closer together?

##of course this is speculation, I'm not informed well
##enough to make an educated guess

Interested in hearing your thoughts about this matter!

Cheers, Jelle.

Jul 18 '05 #1
4 1857
Jelle Feringa // EZCT / Paris wrote:
After reading about extending python with C/Fortran in the excellent
Python Scripting for Computational Science book by Hans Langtangen,
I'm wondering whether there's not a more pythonic way of extending
python. And frankly I think there is: OCAML


There is an even more pythonic way to extend (or embed) python. Have you
looked at Pyrex?

http://nz.cosc.canterbury.ac.nz/~greg/python/Pyrex/
Jul 18 '05 #2
>>>>> "Jelle" == Jelle Feringa // EZCT / Paris <je***********@ezct.net> writes:

Jelle> After reading about extending python with C/Fortran in the
Jelle> excellent Python Scripting for Computational Science book
Jelle> by Hans Langtangen, I'm wondering whether there's not a
Jelle> more pythonic way of extending python. And frankly I think
Jelle> there is: OCAML

For many tasks the point of "extending" python is to gain access to
libraries that have a C/C++ API. Extensions that merely provide a
faster way to do something are much rarer.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #3
Hi !

OCAML is very complementary at Python :

unreadable vs readable
functionnel vs procedural/POO/etc.
compiled vs interpreted (or compil JIT)
very fast vs mean velocity
hard to learn vs easy to easy to learn
Yes, OCAML is very complementary, too much, much too, complementary at
Python...

But, C is not complementary to Python (in the same state of mind).

And, what do you think of... Erlang ?
@-salutations
--
Michel Claveau


Jul 18 '05 #4
Jelle Ferringa wrote:
Since I haven't got actual experience programming CAML I'd like to speculatethat OCAML would be a very pythonic way of extending python: its
open-source, object oriented, as fast as C, and ! garbage collecting!
The open source g95 Fortran 95 compiler is already usable and will be
officially released this year. Fortran and C are comparable in speed,
and if one uses allocatable arrays rather than pointers, memory leaks
should not occur. Fortran 2003 supports OOP with inheritance, and a few
F95 compilers already have this functionality.
That's depending on how you compare; I find OCAML quite readable

compared to C / Fortran .

Have you ever used Fortran 90 or 95?

I don't use OCAML, so I looked at some OCAML code to multiply matrices
at
http://shootout.alioth.debian.org/be...&id=0&sort=cpu
from the Computer Language Shootout . To create a matrix the OCAML code
is

7 let mkmatrix rows cols =
8 let count = ref 1 and last_col = cols - 1
9 and m = Array.make_matrix rows cols 0 in
10 for i = 0 to rows - 1 do
11 let mi = m.(i) in
12 for j = 0 to last_col do mi.(j) <- !count; incr count done;
13 done;

In Python with Numeric it's just

x = zeros([nrow,ncol],Float)

and in Fortran 90/95 it's just

real, allocatable :: x(:,:)
allocate (x(nrow,ncol))

There appears not to be a built-in function for matrix multiplication
in OCAML. There is in Python with Numeric or Numarray or Fortran 90/95.
For problems where the main data structures are arrays, OCAML seems to
be considerably more low-level than Python with Numeric/Numarray or
Fortran 90/95. Also, there exists a vast computational infrastructure
in Fortran and C (see http://www.netlib.org). Does OCAML have this?

Jul 18 '05 #5

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

Similar topics

5
by: Max Powers | last post by:
I've spent an interesting day searching the web for help with calling OCaml functions from a python program and have come to the newsgroup for some advice (unfortunately I'm learning both languages...
0
by: Bryan | last post by:
i've read a few posts about using ocaml as an extension language for python together. has anyone done this? can you write the entire extension in ocaml without having to explicitly write an...
2
by: Gigs_ | last post by:
Is there any way to convert ocaml code to python? but not manually thx
20
by: Mr.SpOOn | last post by:
Hi, I need a structure to represent a set of integers. I also need to perform on this set some basic set operations, such as adding or removing elements, joining with other sets and checking for...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.