http://qs321.pair.com?node_id=11148859

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.

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.

      Inconceivable!

      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