473,763 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1879
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_matr ix 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
3519
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 at the same time, so maybe I've missed something obvious!) The situation is this; I've got a large legacy program that is written in ocaml, within which there's a parser. I'd like to be able to call that parser from my python program (actually...
0
1452
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 additional c wrapper? i was told that ocaml has exportable functions with c bindings. if someone has successfully done this, would you mind posting/sharing an example hello world extension? thanks, bryan
2
3212
by: Gigs_ | last post by:
Is there any way to convert ocaml code to python? but not manually thx
20
2465
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 the presence of specific elements. I think that using Python sets would be the best choice, but I also need integers to be ordered inside the set and I've just found out that, instead, Python sets are unordered collections.
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9998
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
8822
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
7366
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
5270
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
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.