Skip to content

Serialized data #5

@gitonthescene

Description

@gitonthescene

Hi, I realize this isn't actively developed, but I thought I'd mention that with growler/k you can serialize K data. Moreover changes have been made to the repl so that if your command is preceded with two spaces, the output is the serialized data. The idea being that you can deserialize the bytes directly to numpy for instance for access to graphing, etc.

Sample session:

>>> p = Popen(('/Users/XXXX/K/ngnk/growler/k/k','/Users/XXXX/K/ngnk/growler/k/repl.k'),stdin=PIPE,stdout=PIPE,close_fds=False)
>>> p.stdout.readline()
b'ngn/k, (c) 2019-2024 ngn, GNU AGPLv3. type \\ for more info\n'
>>> p.stdin.write('  (1+1;`happy)\n'.encode())
15
>>> p.stdin.flush()
>>> p.stdout.read(1)
b' '
>>> ver = ord(p.stdout.read(1))
>>> serialize.KObjFactory.setVersion(ver)
>>> k = serialize.KObjFactory.create(p.stdout)
>>> k
<2, `happy>
>>> p.stdin.write('  (1+1;`happy;(39.7;9 8 2))\n'.encode())
28
>>> p.stdin.flush()
>>> p.stdout.read(1)
b' '
>>> ver = ord(p.stdout.read(1))
>>> serialize.KObjFactory.setVersion(ver)
>>> k = serialize.KObjFactory.create(p.stdout)
>>> k
<2, `happy, <39.7, [9, 8, 2]>>
>>> p.stdin.write(' (1+1;`happy;(39.7;9 8 2))\n'.encode())
27
>>> p.stdin.flush()
>>> p.stdout.readline()
b' (2;`happy;(39.7;9 8 2))\n'
>>> p.stdin.write('(1+1;`happy;(39.7;9 8 2))\n'.encode())
26
>>> p.stdin.flush()
>>> p.stdout.readline()
b' (2\n'
>>> p.stdout.readline()
b' `happy\n'
>>> p.stdout.readline()
b' (39.7;9 8 2))\n'
>>>

I may try to work out my own kernel but I thought I'd offer the heads up.

Regards,
-Doug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions