Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Compound types should be indexable by field name, not only by position #37

Open
@FrancescAlted

Description

@FrancescAlted

It would be nice if this could work:

In []: t = ndt.type('{key: string; val: int32}')

In []: t['key']
Out[]: ndt.string

In []: t['val']
Out[]: ndt.int32

right now, one is required to do:

In []: t = ndt.type('{key: string; val: int32}')

In []: t[nd.as_py(t.field_names).index('key')]
Out[]: ndt.string

In []: t[nd.as_py(t.field_names).index('val')]
Out[]: ndt.int32

which is far more verbose (and non-trivial to figure out)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions