Skip to main content

Fast array processing functions

Project description

Authors:

Michael Griffin

Version:
2.0.0 for 2017-06-30
License:

This document may be distributed under the Apache 2.0 License.

Language:

Python 3.4 or later


Introduction

The arrayfunc module provides high speed array processing functions for use with the standard Python array module. These functions are patterned after the functions in the standard Python Itertools module together with some additional ones from other sources.

The purpose of these functions is to perform mathematical calculations on arrays faster than using native Python.


Functions

Summary

The functions fall into several categories.

Filling Arrays

Function

Description

count

Fill an array with evenly spaced values using a start and step values.

cycle

Fill an array with evenly spaced values using a start, stop, and step values, and repeat until the array is filled.

repeat

Fill an array with a specified value.

Filtering Arrays

Function

Description

afilter

Select values from an array based on a boolean criteria.

compress

Select values from an array based on another array of boolean values.

dropwhile

Select values from an array starting from where a selected criteria fails and proceding to the end.

takewhile

Like dropwhile, but starts from the beginning and stops when the criteria fails.

Examining and Searching Arrays

Function

Description

aany

Returns True if any element in an array meets the selected criteria.

aall

Returns True if all element in an array meet the selected criteria.

amax

Returns the maximum value in the array.

amin

Returns the minimum value in the array.

findindex

Returns the index of the first value in an array to meet the specified criteria.

findindices

Searches an array for the array indices which meet the specified criteria and writes the results to a second array. Also returns the number of matches found.

Operating on Arrays

Function

Description

amap

Apply an operator to each element of an array, together with an optional second parameter (for operators taking two parameters). The results are written to a second array.

amapi

Like amap, but the results are written in place to the input array.

starmap

Like amap, but where a second array acts as the second parameter. The results are written to an output array.

starmapi

Like starmap, but the results are written in place to the first input array.

asum

Calculate the arithmetic sum of an array.

acalc

Calculate arbitrary equations over an array.

Amap and amapi support more than 70 different operations. Starmap and starmapi support more than two dozen different operations. ACalc supports more than 50 operations.

Data Conversion

Function

Description

convert

Convert arrays between data types. The data will be converted into the form required by the output array.

Attributes

In addition to functions, a set of attributes are provided representing the platform specific maximum and minimum numerical values for each array type. These attributes are part of the “arraylimits” module.


Supported Array Types

Arrayfunc supports all standard Python 3.x array types, as well as the ‘bytes’ type.


Performance

Performance will vary depending on the function, operation, array data type used, and whether overflow checking is enabled.

Average performance increase for amap is 80 times faster than native Python. Functions other than amap, starmap, and acalc average is 50 times faster than native Python. However, some functions and operations may be more than 200 to 300 times faster than native Python.

Detailed performance figures are listed in the documentation.


Platform support

Arrayfunc is written in ‘C’ and uses the standard C libraries to implement the underlying math functions. Arrayfunc has been tested on the following platforms.

OS

Bits

Compiler

Python Version Tested

Ubuntu 16.04 LTS

64 bit

GCC

3.5

Debian 9

32 bit

GCC

3.5

Debian 9

64 bit

GCC

3.5

FreeBSD 11

64 bit

LLVM

3.5

MS Windows 10

64 bit

MS Visual Studio C 2015

3.6


Release History

  • 1.0.0 - First release.

  • 1.1.0 - Added support for math constants math.pi and math.e.

  • 2.0.0 - Many changes. Updated MS Windows support to 3.6 and latest compiler.

    This in turn brought the Windows version up to feature parity with the other versions. Changed supported MS Windows version from 32 bit to 64 bit. Added SIMD support for some functions which provided a significant performance for those affected. Updated supported versions of Debian and FreeBSD to current releases.

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

arrayfunc-2.0.0.tar.gz (104.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

arrayfunc-2.0.0.win-amd64-py3.6.msi (774.1 kB view details)

Uploaded Source

arrayfunc-2.0.0.win-amd64-py3.6.exe (1.4 MB view details)

Uploaded Source

File details

Details for the file arrayfunc-2.0.0.tar.gz.

File metadata

  • Download URL: arrayfunc-2.0.0.tar.gz
  • Upload date:
  • Size: 104.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for arrayfunc-2.0.0.tar.gz
Algorithm Hash digest
SHA256 34f2449746aa3d4014ba686bdef3611b77d193cce0749e6b454ad67cfdf08cac
MD5 cf5a31a20e7e235fad9645c7ac2fb019
BLAKE2b-256 e3bdc065c6b7e8dd68818e2919a476ab771a63be5fa89a5a31646455c4260677

See more details on using hashes here.

File details

Details for the file arrayfunc-2.0.0.win-amd64-py3.6.msi.

File metadata

File hashes

Hashes for arrayfunc-2.0.0.win-amd64-py3.6.msi
Algorithm Hash digest
SHA256 9ff0fe50e10fc358497c4aadae711b24bcddeebb31348f296c6c6d4d35162d2c
MD5 c8044692e056978395a46abce4c9cf06
BLAKE2b-256 0e7737af61eb5bd5c6c1070ae8118da77d03b05fc59d47c2dd9c7af429f3e318

See more details on using hashes here.

File details

Details for the file arrayfunc-2.0.0.win-amd64-py3.6.exe.

File metadata

File hashes

Hashes for arrayfunc-2.0.0.win-amd64-py3.6.exe
Algorithm Hash digest
SHA256 5a5296a5ecb1f7e6126db5b0c7a3d0bd75d9938f9fcac43e63e62b1098e913b3
MD5 e7aa7f26ef7134fe740caa059840e1ae
BLAKE2b-256 dbb77f41af8006c70b4917c20e0b2395ad581045eec13c20864dc903915cdffa

See more details on using hashes here.

Supported by

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