Opened 6 years ago

Closed 3 years ago

#314 closed enhancement (fixed)

[patch] array.pxd - fast Cython access for Python's builtin array.array

Reported by: rk Owned by: andreasvc
Priority: major Milestone: 0.17
Component: Library Keywords:
Cc: brentp

Description

in attachment:

array.pxd


Cython direct interface to Python's array.array type (builtin module).


  • 1D contiguous data view
  • 2D views - contigious or [x,y] transposed/strided
  • tools for fast array creation, maximum C-speed and handiness
  • suitable as allround light weight auto-array within Cython code too

See also: array_example.pyx and doc strings

Note: arrayarray.h (arrayobject, arraydescr) is not part of the official Python C-API so far. Would go into Cython/include/ or python/include/cython/ or next to array.pxd ?

Attachments (6)

array.pxd (9.1 KB) - added by rk 6 years ago.
arrayarray.h (3.5 KB) - added by rk 6 years ago.
array_example.pyx (2.6 KB) - added by rk 6 years ago.
array.zip (6.2 KB) - added by rk 6 years ago.
Update (fast array/buffer concats, and some cleanup)
array.2.zip (6.2 KB) - added by rk 6 years ago.
Update - minor changes
array.simple.diff (14.8 KB) - added by brentp 5 years ago.
update to patch

Download all attachments as: .zip

Change History (14)

Changed 6 years ago by rk

Changed 6 years ago by rk

Changed 6 years ago by rk

comment:1 Changed 6 years ago by rk

  • Component changed from Build System to Optimization

Changed 6 years ago by rk

Update (fast array/buffer concats, and some cleanup)

Changed 6 years ago by rk

Update - minor changes

comment:2 Changed 5 years ago by scoder

  • Summary changed from array.pxd - fast Cython access for Python's builtin array.array to [patch] array.pxd - fast Cython access for Python's builtin array.array

comment:3 Changed 5 years ago by scoder

  • Component changed from Optimization to Library

According to Dag, this needs some cleanup before being added. The proposal is to keep the plain array support simple and move any 2D support into a subclass, as most people will not use it, and its use should be explicit.

Changed 5 years ago by brentp

update to patch

comment:4 Changed 5 years ago by brentp

patch
simplifies some of the stuff above. removes 2d support.
still relies on arrayarray.h (which uses #if macros to support more python version). any comments on how to get that into a .pxi?

comment:5 Changed 5 years ago by brentp

  • Cc brentp added

comment:6 Changed 5 years ago by SamB

Hmm, this seems pretty nice so far, but it doesn't quite build with MSVC (which it must to be usable with the usual Windows builds of Python).

  1. arrayarray.h uses GCC's "mixed declarations and code" extension (in resize_smart())
  2. It also uses the inline reserved word directly, rather than using the Py_LOCAL_INLINE macro to make sure the correct syntax is used for the compiler / settings in question. (This may be especially important considering the fact that at one point, C99 requires exactly-opposite behaviour from that traditionally offered by GCC, but MSVC doesn't even have inline as a keyword, so it's kind of moot.)

comment:7 Changed 3 years ago by scoder

  • Owner changed from somebody to andreasvc

comment:8 Changed 3 years ago by scoder

  • Milestone changed from wishlist to 0.17
  • Resolution set to fixed
  • Status changed from new to closed

Closing as fixed because the most interesting part of this patch has been merged. 2D view support has been deliberately excluded.

Note: See TracTickets for help on using tickets.