Skip to main content

Utils for strongtyping.

Project description

Strongtyping Module

An optional extension for a performance boost for the StrongTyping package https://github.com/FelixTheC/strongtyping
This optional module can boost the performance by factor 3 for simple/single function parameters
and by factor 13 for more complex/multiple function parameters.

Installation

from strongtyping_modules.install import install

install()
  • after this the module is available and will be used automatically from strongtyping

For displaying the performance impact of this optional module I created the following test functions.

@match_typing
def func_with_list(var: List[int]):
    return len(var)


@match_typing
def func_with_set(var: Set[int]):
    return len(var)


@match_typing
def func_with_dict(var: Dict[str, int]):
    return len(var)


@match_typing
def func_with_dict_list(var_1: Dict[str, int], var_2: List[str]):
    return len(var_1) + len(var_2)


@match_typing
def func_list_with_union_1_level(var: List[Union[str, int]]):
    return len(var)

I called each function inside of a loop and with each iteration I used 'i' elements

for i in range(10, 10010, 10):
    func_with_list(list(range(i)))

Here are the results without these module

{'func_list_with_union_1_level': {'max': 0.0824721889985085,
                                  'mean': 0.040940183910031916,
                                  'median': 0.04097814700071467,
                                  'min': 0.00011775800157920457},
 'func_with_dict': {'max': 0.033724983000865905,
                    'mean': 0.01682099703201311,
                    'median': 0.01687698050045583,
                    'min': 5.355300163500942e-05},
 'func_with_dict_list': {'max': 0.3036283949986682,
                         'mean': 0.025529991152990986,
                         'median': 0.02529048100041109,
                         'min': 0.0001045319986587856},
 'func_with_list': {'max': 0.01744058300027973,
                    'mean': 0.008482154103028734,
                    'median': 0.008478498000840773,
                    'min': 3.4947999665746465e-05},
 'func_with_set': {'max': 0.01736680899921339,
                   'mean': 0.008591252664042258,
                   'median': 0.008604455000750022,
                   'min': 3.981400004704483e-05}}

Ande here with these module

{'func_list_with_union_1_level': {'max': 0.017030322000209708,
                                  'mean': 0.008434945453987893,
                                  'median': 0.008279206000224804,
                                  'min': 4.34969988418743e-05},
 'func_with_dict': {'max': 0.004060829000081867,
                    'mean': 0.0020102006380620877,
                    'median': 0.0020167855018371483,
                    'min': 1.697399784461595e-05},
 'func_with_dict_list': {'max': 0.007045086000289302,
                         'mean': 0.003219366065990471,
                         'median': 0.003227623998100171,
                         'min': 2.7607999072642997e-05},
 'func_with_list': {'max': 0.0025434739982301835,
                    'mean': 0.0012344250298920087,
                    'median': 0.001237124501130893,
                    'min': 1.1835003533633426e-05},
 'func_with_set': {'max': 0.002797465000185184,
                   'mean': 0.0012589457310496074,
                   'median': 0.0012730154994642362,
                   'min': 1.298200004384853e-05}}

x Faktor faster for different functions

min       4.178648
mean      4.847373
median    4.796414
max       4.760371
Name: func_list_with_union_1_level, dtype: float64

min       3.177067
mean      7.067269
median    7.284502
max       3.898747
Name: func_with_list, dtype: float64

min       3.103697
mean      6.708103
median    6.790693
max       4.583332
Name: func_with_set, dtype: float64

min       3.303017
mean      8.656822
median    8.794840
max       3.579946
Name: func_with_dict, dtype: float64

min        3.368734
mean       8.407030
median     8.697711
max       13.022075
Name: func_with_dict_list, dtype: float64

Dependencies

  • Cython

Tested for OS

  • Linux, should theoretical work on Windows and MacOs too

Installing

  • pip install strongtyping-modules

Versioning

  • For the versions available, see the tags on this repository.

Authors

  • Felix Eisenmenger

License

  • This project is licensed under the MIT License - see the LICENSE.md file for details

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

strongtyping_modules-0.1.4.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

strongtyping_modules-0.1.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file strongtyping_modules-0.1.4.tar.gz.

File metadata

  • Download URL: strongtyping_modules-0.1.4.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for strongtyping_modules-0.1.4.tar.gz
Algorithm Hash digest
SHA256 5b81ed8b81a0f3a76651f2d25df7651390f70c61a7570c94fd5280027ca62cfd
MD5 ca591bedee2c25a435e6e5203f073271
BLAKE2b-256 4eda4f022b3233905e85573a7808f4a5eb1f6ac96532f2ae4a7bef2f0a07eaeb

See more details on using hashes here.

File details

Details for the file strongtyping_modules-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: strongtyping_modules-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for strongtyping_modules-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 484c5550b1b7728f48a2900b685b7242666777c1aa144b581cf98ebc57cea0f8
MD5 df3b99f012543fa6dd014ca14d8d97f8
BLAKE2b-256 a691e70f31e6e5791b0ff5143ce357eb68cff49260ed251216b5141d32752753

See more details on using hashes here.

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