Ancient
view release on metacpan or search on metacpan
lib/Ancient.pm view on Meta::CPAN
See L<lru> for full documentation.
=head2 object
use object;
object::define('Cat', qw(name age));
my $cat = new Cat 'Whiskers', 3;
print $cat->name;
Objects with prototype chains stored as arrays for speed. Property
accessors are compiled to custom ops. Getters are 2.4x faster and
setters 2x faster than traditional blessed hash references.
See L<object> for full documentation.
=head2 heap
use heap;
my $pq = heap::new('min');
$pq->push(5)->push(1)->push(3);
print $pq->pop; # 1
Binary heap (priority queue) with configurable min/max behavior.
Supports custom comparison callbacks for complex objects.
O(log n) push and pop, O(1) peek.
See L<heap> for full documentation.
=head2 file
use file;
my $content = file::slurp('data.txt');
file::spew('out.txt', $content);
my @lines = file::lines('log.txt');
Fast file operations with custom ops for slurp, spew, exists, size,
and more. Supports atomic writes and memory-mapped reading.
See L<file> for full documentation.
=head2 nvec
use nvec;
my $v = nvec::new([1, 2, 3, 4]);
my $sum = $v->sum;
my $scaled = $v->scale(2.0);
Numeric vectors with SIMD acceleration for mathematical operations.
Provides fast arithmetic, reductions, linear algebra, and element-wise
math functions.
See L<nvec> for full documentation.
=head1 CUSTOM OP OPTIMIZATION
Many functions in Ancient modules are compiled to custom ops at compile time
for performance. This optimization is transparent - the functions
work identically whether optimized or not.
=head2 Full Context Support
Custom ops work correctly in all Perl contexts including C<map>, C<grep>,
C<for>/C<foreach> loops, and C<while> loops - both with the implicit C<$_>
variable and with explicit lexical loop variables:
# All of these use optimized custom ops:
my @clamped = map { util::clamp($_, 0, 100) } @values;
my @existing = grep { file::exists($_) } @paths;
my @evens = grep { util::is_even($_) } @numbers;
for (@keys) {
my $val = $cache->get($_);
}
for my $i (@nums) {
push @results, util::clamp($i, 0, 100);
}
The custom ops properly handle both C<$_> (implemented as OP_RV2SV->OP_GV)
and lexical loop variables (PADSV) in all contexts.
=head1 AUTHOR
LNATION <email@lnation.org>
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
( run in 2.279 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )