[issue10030] Patch for zip decryption speedup
Shashank
report at bugs.python.org
Sat Oct 23 23:22:11 CEST 2010
Shashank <shashank.sunny.singh at gmail.com> added the comment:
>the C module should be private and therefore called _zipdecrypt
done
>if you want to avoid API mismatch, you could give a tp_call to your C >decrypter object, rather than a "decrypt" method
done
>- you can put all initialization code in zipdecrypt_new and avoid the >need for zipdecrypt_init
keeping this similar to the existing _ZipDecrypter class in ZipFile (all initialization in init rather than new), which was probably to allow re-init and re-use of one instance
>it's better to use the "y*" code in PyArg_ParseTuple, rather than "s#"
y* does not seem to be available in 2.7, using s* instead
>you should define your module as PY_SSIZE_T_CLEAN and use Py_ssize_t >as length variables (rather than int)
done
>you *mustn't* change the contents of the buffer which is given you by >"s#" or "y*", since that buffer is read-only (it can be a bytes >object); instead, create a new bytes object using >PyBytes_FromStringAndSize(NULL, length) and write into that; or, if >you want a read-write buffer, use the "w*" code
corrected, not altering the input buffer, reading input buffer as s*
----------
Added file: http://bugs.python.org/file19347/zipdecrypt.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10030>
_______________________________________
More information about the Python-bugs-list
mailing list