Author vstinner
Recipients ebfe, vstinner
Date 2009-01-17.02:20:44
SpamBayes Score 0.00633982
Marked as misclassified No
Message-id <1232158847.59.0.281992730118.issue4821@psf.upfronthosting.co.za>
In-reply-to
Content
sha1module_small_locks.diff patch is very similar to the changes made 
in #4751, except:
 - SHA1_GIL_MINSIZE is 8192 whereas HASHLIB_GIL_MINSIZE is 2048
 - There is no test for PyThread_allocate_lock() failure

Instead of copy/paste code in hashlib, sha1, sha256 and sha512 (4 
modules), can't we share some constants, functions or macros? 
Examples:
 - the GIL minimum size constant
 - the long MY_GET_BUFFER_VIEW_OR_ERROUT macro (which can be a 
function)

And about sha, why using 3 files for sha? Are the source code so 
different? In the GNU libc, they use "template" files (it's possible 
even with the C language using the preprocessor!): strtof(), strtod() 
and strtold() share 99% of the source code. Interesting content of 
strtof.c :
----
#define	FLOAT		float
#define	FLT		FLT
#ifdef USE_WIDE_CHAR
#define STRTOF		wcstof
#define STRTOF_L	__wcstof_l
#else
# define STRTOF		strtof
# define STRTOF_L	__strtof_l
#endif

#include "strtod.c"
----

Refactoring to share code between hash modules will ease the changes, 
eg. release the GIL ;-)
History
Date User Action Args
2009-01-17 02:20:47vstinnersetrecipients: + vstinner, ebfe
2009-01-17 02:20:47vstinnersetmessageid: <1232158847.59.0.281992730118.issue4821@psf.upfronthosting.co.za>
2009-01-17 02:20:46vstinnerlinkissue4821 messages
2009-01-17 02:20:44vstinnercreate