Code Monkey home page Code Monkey logo

Comments (6)

happyleavesaoc avatar happyleavesaoc commented on August 28, 2024

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.

denniske avatar denniske commented on August 28, 2024

Yes that sounds good. An example would be great :)

from aoc-mgz.

happyleavesaoc avatar happyleavesaoc commented on August 28, 2024

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.

denniske avatar denniske commented on August 28, 2024

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.

happyleavesaoc avatar happyleavesaoc commented on August 28, 2024

@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.

denniske avatar denniske commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.