Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'interfaces': 0.04; 'startup': 0.05; 'subject:Python': 0.06; 'cache': 0.07; 'socket': 0.07; 'executable': 0.09; 'executed': 0.09; 'moreover,': 0.09; 'slow.': 0.09; 'windows,': 0.09; 'worse': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'windows': 0.15; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'latter,': 0.16; 'libraries.': 0.16; 'parts.': 0.16; 'taking.': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; 'code,': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'install': 0.23; 'creating': 0.23; 'instance,': 0.24; 'library,': 0.24; 'tend': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'developing': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'go.': 0.31; 'figure': 0.32; 'run': 0.32; 'quite': 0.32; 'linux': 0.33; 'running': 0.33; 'guess': 0.33; "i'd": 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'disk': 0.36; 'done,': 0.36; 'ram': 0.36; 'possible': 0.36; 'so,': 0.37; 'writes': 0.38; 'does': 0.39; 'called': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'easy': 0.60; 'up,': 0.60; 'simply': 0.61; "you're": 0.61; 'further': 0.61; 'first': 0.61; 'such': 0.63; 'face': 0.64; 'management': 0.65; 'account': 0.65; 'between': 0.67; 'details,': 0.68; 'response.': 0.68; '****': 0.68; '20,': 0.68; 'methodology': 0.68; 'reads': 0.68; 'to,': 0.72; '2015': 0.84; 'divide': 0.84; 'hard.': 0.84; 'step,': 0.84; 'opens': 0.91; 'to:none': 0.92; 'kit': 0.97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=Etf1vZNtArbiv1KYizz79vKgMtAIZI23c2HckEkgcVk=; b=gwF7lTQgbYpkrGLjVjjhLi+e9hNZv8o3K48EGZMPBovJ3vhZ+Glj7a3hbVhTFYUI2o sBue6rvR4x2RY0ikY+B6nGnXatEiKCoAsOm5LcYNg0pLu6bthaFNiXaeVlVNoWZ7wPlo manSLSmI/pplDhIYjq1d1VfhSonG3/SRsbp6LP34DYsjveibTLaSCeRNZZAssP3UPxlx h740rBAYkwUTO+hV7KLH8/wj4vQiIx6RFh3A8it0tz4g9gbPe1v2FzWluiAoF/qPJi8P MjBdespgk5kn1sQaDYOu8/8Tuy0sDFJwVyBPUIoBe/ADYIhmigxbFzHFfDGaysCKSrMX 1a/w== MIME-Version: 1.0 X-Received: by 10.50.141.164 with SMTP id rp4mr15735831igb.2.1429456985338; Sun, 19 Apr 2015 08:23:05 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Apr 2015 01:23:05 +1000 Subject: Re: Python and fortran Interface suggestion From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1429456993 news.xs4all.nl 2824 [2001:888:2000:d::a6]:57311 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6148 X-Received-Body-CRC: 1528455572 Xref: csiph.com comp.lang.python:89159 On Mon, Apr 20, 2015 at 12:48 AM, pauld11718 wrote: > I am developing a code under Ubuntu(64bit) with python using various libr= aries. Once done, I need to generate an executable which shall be interface= d with fortran program on account of further collaboration. The python exec= utable shall be used with windows(32bit). > > So, I guess everytime my python executable is called by the fortran code = on each time step, all those > from **** import *'s > will be executed and are time consuming (which is not at all required). M= oreover, creating executable for windows, using linux is that possible by a= ny means? > > What is a better methodology for addresing such interfacing? Hmm. Let's divide that into several parts. 1) You need to have a Python program that interfaces with Fortran. Does it need to call functions from a Fortran library, or is it simply invoked by the Fortran program and that's it? If the latter, it's not hard. But if you're concerned about startup time, you may want to consider having your Python program keep running indefinitely, and have some alternative means of communicating between them. For instance, Python might create a socket or pipe, which the Fortran program opens and writes to, and then reads a response. (If you can't edit the Fortran code at all, it's pretty easy to write a slim stub executable that does the socket/pipe handling.) Or alternatively, install Python onto a RAM disk, to improve startup time that way. 2) You need to run the whole kit and caboodle on Windows. The best way to do this is simply to write clean Python code, and then install a Windows Python, and everything will work just fine. However, Windows does tend to have far worse disk cache management than Linux has, which will exacerbate your startup delays. 3) Above all, you need to know exactly how long things are taking. Before you start trying to speed things up, first figure out where it's actually slow. You never know, it might already be fast enough! Check out some details, see how things go. On the face of it, I'd guess that what you want to do will be quite doable. ChrisA