From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Germ=C3=A1n_Diago?= Newsgroups: gmane.lisp.guile.user Subject: Re: Playing with guile (vs python). Generate file for GDP suitable for gnuplot. Date: Wed, 1 Feb 2017 10:56:59 +0700 Message-ID: References: <87tw8fjc34.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1485921463 22071 195.159.176.226 (1 Feb 2017 03:57:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 1 Feb 2017 03:57:43 +0000 (UTC) Cc: guile-user@gnu.org To: Arne Babenhauserheide Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Feb 01 04:57:38 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYm38-0005XA-Gz for guile-user@m.gmane.org; Wed, 01 Feb 2017 04:57:38 +0100 Original-Received: from localhost ([::1]:42599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYm3D-0002eU-V3 for guile-user@m.gmane.org; Tue, 31 Jan 2017 22:57:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYm2r-0002eN-NR for guile-user@gnu.org; Tue, 31 Jan 2017 22:57:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYm2q-0007LJ-Oh for guile-user@gnu.org; Tue, 31 Jan 2017 22:57:21 -0500 Original-Received: from mail-yb0-x235.google.com ([2607:f8b0:4002:c09::235]:33111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYm2q-0007LD-Iu for guile-user@gnu.org; Tue, 31 Jan 2017 22:57:20 -0500 Original-Received: by mail-yb0-x235.google.com with SMTP id w194so240326890ybe.0 for ; Tue, 31 Jan 2017 19:57:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=d2+N+xcbQtfLvaGen+RZu7xseWX1fE6rHz/g4RDOQMk=; b=dO0O9oQ1Hz/k51lqHOgInuJGzTQqUcovJ5PhyueLjG+fR+DvBlO1gVt3MQuxVAfI1l dl5KBzgj8K9BxG2kk955Bo8Snwup4b3pTQqEBgiuY4cR0j8IDv5QHq/9HuBbDCsY8O/d KzYkZbWxlWgDY2AEB8eMNGM6g4S6Qc95uY6hzuqWkDq4bVZCJQwmEXKvIy10wbL1okTw D0sM07kCW1FTZ0LqO7v9UDHti0gqiCvSFWmIEffzwKSm5V0nGQ3NYvi08ypjUf0qsB/y MSVpzuSL4qshmGIRlt3q0Voi0zQCzZ7USdU5H868w2y9RZ1Rmiz3MoYXtmyiqUlVOsli Nybg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=d2+N+xcbQtfLvaGen+RZu7xseWX1fE6rHz/g4RDOQMk=; b=M8ZvClNmLJuEaw9Vz0ZccvtseqM0lrmP7G/y3hNssm/VZK94vJmzhvOTJIp39F/dty q2uAF5WravdOv4m58PXsw80NZxmsIk8y/PHZs4Hqu9fl/UGR8bLbNQReoKtyKlagaWvO 4vVw3oUtex4Zt7UpP3yVXAZ46S1dB5sjrD9YPSH29mFn07SGjsLkf2+pRiMQugiujZXn OUsnCXtc1Fwc/nUaBr0hbj8WmBrZnN68TJiaMjUx4++oXx9cw9S1Egk64bpI5kmvGeA9 yis4x6hMd+LaGqaCL9/biBJCoCZEPmEM6xDDI9OKUfLAI+3bgwtBVDDr3tkk+2xAZwiH ++eQ== X-Gm-Message-State: AIkVDXJPXcVfPwOdlWvfKAPqiqEcXlbdQwtLJSY1HGCpeMEpqoSLKVDZuyVpTlVL7KBx1rlbnHJlCfHcydvZ3w== X-Received: by 10.37.106.67 with SMTP id f64mr485428ybc.196.1485921439526; Tue, 31 Jan 2017 19:57:19 -0800 (PST) Original-Received: by 10.37.99.130 with HTTP; Tue, 31 Jan 2017 19:56:59 -0800 (PST) In-Reply-To: <87tw8fjc34.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c09::235 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13162 Archived-At: > > If I understand your script correctly, you want to grab all lines with > GDP, sort the values by year and country and output them. Is that right? > > As a first warning: the csv module in Python mainly calls into a C-based > implementation (_csv, see csv.__file__), so it will be hard to beat this > in pure Scheme. > > Good to know. > But now, let=E2=80=99s begin with the optimization. These are my times: > > $ time guile-2.0 extract_gdp.scm > real 0m0.509s > $ time python3 extract_gdp.py > real 0m0.089s > > The first step is using Guile 2.1.6 instead of 2.0. That reduces the > runtime by 40% to 0.3s. Source: ftp://alpha.gnu.org/gnu/guile/ > guile-2.1.6.tar.xz > > Thanks. > $ time guile extract_gdp.scm > real 0m0.296s > $ time python3 extract_gdp.py > real 0m0.089s > > So there=E2=80=99s a factor of 3.3 between Python and Guile on my machine= . > > > Aside from using a more recent Guile, I do not see obvious > optimizations, however (more exactly: all my tries to speedup the code > only made it slower). > I was struggling with using read-line! instead of read-line but experimenting in the command line I cannot figure out how it works actually. read-line! will reuse a buffered string. There was lots of time spent there, I am not sure if because of allocations or just because of I/O. If someone could tell me how to do it..= . Thanks for your time Arne!