Skip Menu |

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 125863
Status: open
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Progressive loading of Exporter.pm
Could save a little time and memory and avoid loading Exporter.pm for those people who don't want to import any functions. Basically, get rid of the `require Exporter` in Scalar::Util, List::Util, and Sub::Util, and replace it with your own `import` sub: sub import { return unless @_; require Exporter; my $import = \&Exporter::import; no warnings "redefine"; *import = $import; goto $import; } This means that people who want to do: use Scalar::Util; if (Scalar::Util::looks_like_number($foo)) { ...; } ... won't have Exporter.pm loaded into memory. Yeah, I know it's only a small module if you don't accidentally trigger Exporter::Heavy getting loaded. But given how essential Scalar::Util and its friends are, I think it's worth considering.
On Tue Jul 17 03:58:27 2018, TOBYINK wrote: Show quoted text
> Could save a little time and memory and avoid loading Exporter.pm for > those people who don't want to import any functions. > > Basically, get rid of the `require Exporter` in Scalar::Util, > List::Util, and Sub::Util, and replace it with your own `import` sub: > > sub import { > return unless @_; > require Exporter; > my $import = \&Exporter::import; > no warnings "redefine"; > *import = $import; > goto $import; > } > > This means that people who want to do: > > use Scalar::Util; > > if (Scalar::Util::looks_like_number($foo)) { > ...; > } > > ... won't have Exporter.pm loaded into memory. > > Yeah, I know it's only a small module if you don't accidentally > trigger Exporter::Heavy getting loaded. But given how essential > Scalar::Util and its friends are, I think it's worth considering.
This would break calls to ->export_to_level. Obviously you could also add a delegated sub for that, but that seems like a lot of boilerplate for a pretty small gain.
On Tue Jul 17 03:58:27 2018, TOBYINK wrote: Show quoted text
> Could save a little time and memory and avoid loading Exporter.pm for > those people who don't want to import any functions. > > Basically, get rid of the `require Exporter` in Scalar::Util, > List::Util, and Sub::Util, and replace it with your own `import` sub: > > sub import { > return unless @_; > require Exporter; > my $import = \&Exporter::import; > no warnings "redefine"; > *import = $import; > goto $import; > } > > This means that people who want to do: > > use Scalar::Util; > > if (Scalar::Util::looks_like_number($foo)) { > ...; > } > > ... won't have Exporter.pm loaded into memory. > > Yeah, I know it's only a small module if you don't accidentally > trigger Exporter::Heavy getting loaded. But given how essential > Scalar::Util and its friends are, I think it's worth considering.
You would also need to add a delegate method for export_to_level. Given the amount of boilerplate needed (across 3 modules), I don't think it is worth it for the very small gain.