Skip Menu |

This queue is for tickets about the Digest-SHA CPAN distribution.

Report information
The Basics
Id: 82656
Status: rejected
Worked: 30 min
Priority: 0/
Queue: Digest-SHA

People
Owner: Nobody in particular
Requestors: victor [...] vsespb.ru
Cc:
AdminCc:

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



Subject: Feature request dump/load to string
Hello. I am working on Amazon Glacier client code (https://github.com/vsespb/mt-aws-glacier/), so Glacier checksum calculation organized the way that I really need call clone() to get up to 100% performance win when uploading small files. ( Thing is Amazon Glacier need two checksums - one is sha256 for file, Another is TreeHash (tree hash consist of sha256 with 1 Mb chunks) - so checksum for first 1M is calculated twice.) Well, would be great to have dump/load to string, not to a file, because my application is multithreaded (using fork) and I will need to pass SHA object via socket (thus I cannot clone, I need load/dump but it's kind of inconvenient to use external filesystem for this).
On Sat Jan 12 10:16:11 2013, vsespb wrote: Show quoted text
> Well, would be great to have dump/load to string, not to a file, because > my application is multithreaded (using fork) and I will need to pass SHA > object via socket (thus I cannot clone, I need load/dump but it's kind > of inconvenient to use external filesystem for this).
Capturing the output of dump to a string is easily achievable by adding a several-line subroutine to your application. Using CPAN's Capture::Tiny, it's even possible in a single line, e.g. $s = capture_stdout { Digest::SHA->new($alg)->add($data)->dump }; By contrast, modifying Digest::SHA to capture the output of dump to a string incurs a large cost by making each digest object (struct SHA) about 600 bytes larger at the C level, and correspondingly larger at the Perl level. This would kill the performance of many existing applications that create huge numbers of simultaneous digest objects. Bear in mind that Digest::SHA is a core module that's already quite sizable due its complete implementation of the SHA standard. Adding convenience features is generally discouraged unless it can be done at little to no cost. In this case, the cost is unacceptably high.