Message175762
With issue #15031 providing a way to take a bytecode file and get a code object out of it, there should probably be a comparable method that takes a code object and a path stats dict and returns the bytes to write out to a file.
This could also be a slight performance win for subclasses of SourceLoader which can read bytecode files but not write them (e.g. zip files where the cost of modifying a zip file is too high). That way the method could raise NotImplementedError (or return None) to signify it doesn't want anything written out by SourceLoader.get_code() and thus skip the entire step of preparing the bytecode file bytes instead of what happens now where set_data() raises NotImplementedError after the whole set of bytes is constructed.
More importantly, it would clean up py_compile once issue #15627 is in with an 'optimize' flag as py_compile.compile() would essentially become ``source = loader.get_source(...); code = loader.compile_source(source, optimize=...); pyc_bytes = loader.create_bytecode_file(code, loader.path_stats(...))``. Otherwise get_code() will need to grow an 'optimize' flag and that doesn't seem necessary. |
|
Date |
User |
Action |
Args |
2012-11-17 16:00:17 | brett.cannon | set | recipients:
+ brett.cannon |
2012-11-17 16:00:17 | brett.cannon | set | messageid: <1353168017.12.0.0693705888433.issue16494@psf.upfronthosting.co.za> |
2012-11-17 16:00:17 | brett.cannon | link | issue16494 messages |
2012-11-17 16:00:16 | brett.cannon | create | |
|