Skip to main content

Extracting data structures from runtime duck typing.

Project description

git init# duckstruct

Dependencies: None
Developer: Emmanouil (Manios) Krasanakis
Contant: maniospas@hotmail.com

Quickstart

from duckstruct import TypeListener
import numpy as np

x = np.array([1, 2, 3])
y = np.array([5, 6])
z = np.array([7.])
x = TypeListener(x)
y = TypeListener(y)
z = TypeListener(z)
print(x)
print(x+1+y.sum()+z.sum())

After running the code, you can show the structure a new variable should have to replace all others in yaml format.

print(x.type() & y.type() & z.type())

This yields the minimum necessary structure for the code to run:

object:
  __str__: 
    returns:
      class: str
  __add__: 
    returns:
      class: ndarray
  sum: 
    returns:
      -  class: int32
      -  class: float64

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

duckstruct-0.0.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

duckstruct-0.0.1-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page