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.3.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

strongtyping_modules-0.1.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strongtyping_modules-0.1.3.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for strongtyping_modules-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cfdaf8c2ae3b273058fae2c15029603c19035d772be09f8a86e97c3f20b0dadd
MD5 198d01500603f5b40e5c78a34acae84e
BLAKE2b-256 16d7ef85c15d46582bdddc75f6365c64a481f1036510ee5989dbe1d7c38c5d49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: strongtyping_modules-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for strongtyping_modules-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d8b2ad0b579f11feea6306ce23ae71096c0710d928a60da31099ba6c2dcc651b
MD5 63d3a2c9eac273832ce021f43b7bcc5a
BLAKE2b-256 358012d465ba4fae9b953e08e598cf4effc2bcca80cbe9937aba2f6a12d732af

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