Comments (6)
Most of the time is probably spent parsing the header. "fast mode" only affects the body right now. If you only need those two pieces of data, you could skip parsing the header entirely (read header length, then skip forward to read the body -- I can provide an example if you want).
from aoc-mgz.
Yes that sounds good. An example would be great :)
from aoc-mgz.
Here's an example:
import struct
import os
from mgz import header, fast
with open('/path/to/file', 'rb') as data:
eof = os.fstat(data.fileno()).st_size
prefix_size = 8
header_len, next_header = struct.unpack('<II', data.read(prefix_size))
data.read(header_len - prefix_size) # read but don't parse header bytes
fast.meta(data)
while data.tell() < eof:
fast.operation(data)
from aoc-mgz.
Thanks for the sample. It worked for me.
Though I assume it will not return the correct duration for restored matches, if I the header is skipped? Because the time where the restored match starts, is written in the header at self._header.initial.restore_time
?
from aoc-mgz.
@denniske Depends on if you want the duration of the rec or the match. If you want the match duration, yes, you will need to add the restore_time
.
from aoc-mgz.
Thanks for the clarification. I assume for most matches skipping header will be okay then.
Btw: Have you been online on discord lately? I have some questions unrelated to this repository which I think you know something about. Would be cool if you could check them there.
from aoc-mgz.
Related Issues (20)
- Decoding error when calling summary.Summary() HOT 3
- Unable to run any of the examples provided on the main page HOT 6
- construct.core.MappingError - Same error consistently HOT 2
- crash since v101.101.61591.0 - construct.core.MappingError: no decoding mapping for 8 HOT 2
- construct.core.MappingError: no decoding mapping for 8 HOT 1
- Parsing incorrect bytes when using summary snippet in README file HOT 4
- Unable to use JSON parser HOT 6
- collections.Hashable -> collections.abc.Hashable HOT 1
- RuntimeError: bad object parse HOT 11
- How to merge two games that share a common point? HOT 1
- Issue using parse_match() function in python 3.10 HOT 5
- how do you generate minimaps? HOT 2
- What is playback? HOT 2
- struct.error: unpack requires a buffer of 4 bytes HOT 1
- error: construct.core.PaddingError: subcon parsed more bytes than was allowed by length HOT 4
- RuntimeError: bad object parse HOT 2
- AI learning from recordings HOT 3
- Full summary isn't working HOT 5
- Consider add documentation? HOT 1
- Read chapter information HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aoc-mgz.