Speed up BlendFileBlock instantiation with __slots__
Due to the huge number of BlendFileBlock objects created for packing a production-size blend file, using slots here actually makes the dependency tracer significantly (p<0.001) faster. In my test case the speed improvement was 16% for a 'bam list' command.
This commit is contained in:
parent
88f23a4097
commit
f2f824ad85
@ -38,7 +38,6 @@ from blender_asset_tracer import bpathlib
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
FILE_BUFFER_SIZE = 1024 * 1024
|
FILE_BUFFER_SIZE = 1024 * 1024
|
||||||
|
|
||||||
BLENDFILE_MAGIC = b'BLENDER'
|
BLENDFILE_MAGIC = b'BLENDER'
|
||||||
GZIP_MAGIC = b'\x1f\x8b'
|
GZIP_MAGIC = b'\x1f\x8b'
|
||||||
|
|
||||||
@ -378,6 +377,16 @@ class BlendFileBlock:
|
|||||||
"""
|
"""
|
||||||
Instance of a struct.
|
Instance of a struct.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Due to the huge number of BlendFileBlock objects created for packing a
|
||||||
|
# production-size blend file, using slots here actually makes the
|
||||||
|
# dependency tracer significantly (p<0.001) faster. In my test case the
|
||||||
|
# speed improvement was 16% for a 'bam list' command.
|
||||||
|
__slots__ = (
|
||||||
|
'bfile', 'code', 'size', 'addr_old', 'sdna_index',
|
||||||
|
'count', 'file_offset', 'endian', '_id_name',
|
||||||
|
)
|
||||||
|
|
||||||
log = log.getChild('BlendFileBlock')
|
log = log.getChild('BlendFileBlock')
|
||||||
old_structure = struct.Struct(b'4sI')
|
old_structure = struct.Struct(b'4sI')
|
||||||
"""old blend files ENDB block structure"""
|
"""old blend files ENDB block structure"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user