Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Why are cpan modules so slow to install?

by silent11 (Vicar)
on Dec 14, 2022 at 15:21 UTC ( [id://11148859]=perlquestion: print w/replies, xml ) Need Help??

silent11 has asked for the wisdom of the Perl Monks concerning the following question:

I'm asking sincerely, I'm not looking to criticize, or start a religious war. I'm curious on a technical level why the process takes so long, compared to say, Python modules. My typical experience is it takes seconds to install most Python modules and their dependencies, where Perl usually takes minutes, and will come with dozens of dependencies. This has been my observation as someone who develops Perl and Python on my local machines, both at work and home, however the same holds true when building docker images remotely, so it's not like Perl is just slow on "my machine".

I hate to say it, but the only other module system that I'm familiar with, that takes as-long or longer to build out modules is npm.

  • Comment on Why are cpan modules so slow to install?

Replies are listed 'Best First'.
Re: Why are cpan modules so slow to install?
by GrandFather (Saint) on Dec 14, 2022 at 20:13 UTC

    I agree that many of the modules I install using cpanm take a long time, where long can be tens of minutes. There are reasons:

    • Many modules have a compiled C component which is compiled on the local machine.
    • Almost all modules depend on other modules - that's kinda the point of having a module library in the first place. If the dependencies aren't already installed they need to be fetched and installed - rinse and repeat.
    • Good modules come with comprehensive test suites that are run on your machine to check that there isn't some unforeseen incompatibility or bug due to your environment.

    My limited understanding of Python module installs is that they amount to copying a file. From what I've seen there is no install time dependency checking. I may be misremembering on both assertions, but if not the work that is done for a Perl module install is very different than Python. In principle that means that a Perl module that installs correctly should have everything it needs to actually work correctly on your machine. My very limited experience with Python is that is not generally the case.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re: Why are cpan modules so slow to install?
by choroba (Cardinal) on Dec 14, 2022 at 16:01 UTC
    What do you use to install the modules?

    The default tool, cpan, runs tests for every distribution installed. You can use the -T option to skip tests.

    There are alternative CPAN clients, e.g. cpanm or cpanp. The former uses -n or --notest and the latter uses --skiptest to achieve the same.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      I use `cpanm`
Re: Why are cpan modules so slow to install?
by stevieb (Canon) on Dec 14, 2022 at 16:52 UTC

    Knowing which Perl distributions and Python modules you're referring to would allow us to decide whether there is a fair comparison here.

    Single module pure Perl distributions that have an adequate test suite take mere seconds to install.

      it's not that simple, there is no apples to apples comparison. This is my experience in general, not matter what I install. Great points from GrandFather give me some avenues to research.
Re: Why are cpan modules so slow to install?
by gnosti (Chaplain) on Dec 16, 2022 at 00:34 UTC
    To install modules faster, try App::cpm. It uses parallel processes and can be very fast.


      I just installed `Catalyst` and all it's dep's in under 20 seconds. How have I not heard of this before?!?!?!

      Thank you for sharing this!

      Edit: wait, this isn't compatible with plenv is it? :(

      Edit 2:ah, `--global` flag looks like what I need.

        maybe you should check task::kensho regularly. ;)

        I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11148859]
Approved by choroba
Front-paged by Corion
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-13 08:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found