> > 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’s 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’s 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!