-
-
Notifications
You must be signed in to change notification settings - Fork 8
docs: add optype.numpy.ctypeslib reference page
#581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Aniketsy
wants to merge
12
commits into
jorenham:master
Choose a base branch
from
Aniketsy:fix-448
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
58d1cf4
docs: add optype.numpy.ctypeslib reference page
Aniketsy aa2285c
Update docs/reference/numpy/ctypeslib.md
Aniketsy fbfed32
Update docs/reference/numpy/ctypeslib.md
Aniketsy 13384d7
define ct
Aniketsy afbebbc
improve and address review pointers
Aniketsy 2d5cb00
Update docs/reference/index.md
Aniketsy 887e631
Merge branch 'master' into fix-448
jorenham b98c4d7
improve docs and structure
Aniketsy 9018179
Merge branch 'master' into fix-448
Aniketsy 8df68c4
improve docs
Aniketsy 0e05abd
improve doc as per review
Aniketsy 449b2c5
Update docs/reference/index.md
Aniketsy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # `optype.numpy.ctypeslib` | ||
|
|
||
| Typed `ctypes` aliases for NumPy scalar-like C types. | ||
|
|
||
| `optype.numpy.ctypeslib` reexports standard-library `ctypes` constructors using | ||
| names that mirror NumPy scalar naming (for example, `Int32` for `np.int32`-like | ||
| typing), and it exposes abstract `ctypes` type aliases for static typing. | ||
|
|
||
| The module assumes a C99-compatible platform with either a 32- or 64-bit data model. | ||
|
|
||
| ```python | ||
| import ctypes as ct | ||
| ``` | ||
|
|
||
| ## Reexported `ctypes` constructors | ||
|
jorenham marked this conversation as resolved.
Outdated
|
||
|
|
||
| <table> | ||
| <tr> | ||
| <th align="left"><code>optype.numpy.ctypeslib</code></th> | ||
| <th align="left"><code>ctypes</code></th> | ||
| <th align="left">kind</th> | ||
| <th align="left">notes</th> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Bool</code></td> | ||
| <td align="left"><code>c_bool</code></td> | ||
| <td align="left">boolean</td> | ||
| <td align="left"></td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Int8</code>, <code>UInt8</code>, <code>Int16</code>, <code>UInt16</code>, <code>Int32</code>, <code>UInt32</code>, <code>Int64</code>, <code>UInt64</code></td> | ||
| <td align="left"><code>c_int8</code>, <code>c_uint8</code>, <code>c_int16</code>, <code>c_uint16</code>, <code>c_int32</code>, <code>c_uint32</code>, <code>c_int64</code>, <code>c_uint64</code></td> | ||
| <td align="left">fixed-width integers</td> | ||
| <td align="left"></td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Byte</code>, <code>UByte</code>, <code>Short</code>, <code>UShort</code>, <code>IntC</code>, <code>UIntC</code>, <code>IntP</code>, <code>UIntP</code>, <code>Long</code>, <code>ULong</code>, <code>LongLong</code>, <code>ULongLong</code></td> | ||
| <td align="left"><code>c_byte</code>, <code>c_ubyte</code>, <code>c_short</code>, <code>c_ushort</code>, <code>c_int</code>, <code>c_uint</code>, <code>c_ssize_t</code>, <code>c_size_t</code>, <code>c_long</code>, <code>c_ulong</code>, <code>c_longlong</code>, <code>c_ulonglong</code></td> | ||
| <td align="left">platform-width integers</td> | ||
| <td align="left"><code>UIntP</code> uses <code>c_size_t</code> (<code>void_p</code> on NumPy < 2, but almost always equivalent).</td> | ||
|
jorenham marked this conversation as resolved.
Outdated
|
||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Float32</code>, <code>Float64</code>, <code>LongDouble</code></td> | ||
| <td align="left"><code>c_float</code>, <code>c_double</code>, <code>c_longdouble</code></td> | ||
| <td align="left">floating-point</td> | ||
| <td align="left"><code>LongDouble</code> is mainly useful as a type annotation target.</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Complex64</code>, <code>Complex128</code>, <code>CLongDouble</code></td> | ||
| <td align="left"><code>c_float_complex</code>, <code>c_double_complex</code>, <code>c_longdouble_complex</code></td> | ||
| <td align="left">complex floating-point</td> | ||
| <td align="left">Available on Python 3.14+ on non-Windows only; otherwise these aliases are <code>Never</code>.</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Bytes</code></td> | ||
| <td align="left"><code>c_char</code></td> | ||
| <td align="left">character/byte</td> | ||
| <td align="left">Not numeric; participates in <code>Flexible</code>.</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Object</code></td> | ||
| <td align="left"><code>py_object</code></td> | ||
| <td align="left">Python object reference</td> | ||
| <td align="left"></td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| ## Abstract type aliases | ||
|
|
||
| <table> | ||
| <tr> | ||
| <th align="left">alias</th> | ||
| <th align="left">covers</th> | ||
| <th align="left">notes</th> | ||
| </tr> | ||
|
jorenham marked this conversation as resolved.
Outdated
|
||
| <tr> | ||
| <td align="left"><code>CType</code></td> | ||
| <td align="left"><code>ctypes._SimpleCData[T]</code></td> | ||
| <td align="left">Scalar-value ctypes base type.</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>CScalar</code></td> | ||
| <td align="left"><code>ctypes._CData</code></td> | ||
| <td align="left">Broad base for ctypes objects (scalar, array, pointer, structure, union, ...).</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Array</code></td> | ||
| <td align="left"><code>ct.Array[CT]</code> (including nested arrays)</td> | ||
| <td align="left"><code>CT</code> is bound to <code>CType</code>.</td> | ||
|
jorenham marked this conversation as resolved.
Outdated
|
||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>SignedInteger</code>, <code>UnsignedInteger</code></td> | ||
| <td align="left">signed and unsigned integer constructor groups</td> | ||
| <td align="left"></td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Integer</code>, <code>Floating</code>, <code>ComplexFloating</code></td> | ||
| <td align="left">numeric scalar families</td> | ||
| <td align="left">Modeled via <code>CScalar</code> for static typing.</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Inexact</code>, <code>Number</code></td> | ||
| <td align="left">combined numeric families</td> | ||
| <td align="left"><code>Inexact = Floating | ComplexFloating</code>, <code>Number = Integer | Floating | ComplexFloating</code>.</td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Void</code></td> | ||
| <td align="left"><code>ct.Structure | ct.Union</code></td> | ||
|
jorenham marked this conversation as resolved.
Outdated
|
||
| <td align="left">Not a constructor reexport; structural ctypes only.</td> | ||
|
jorenham marked this conversation as resolved.
Outdated
|
||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Flexible</code></td> | ||
| <td align="left"><code>Bytes | Void</code></td> | ||
| <td align="left"></td> | ||
| </tr> | ||
| <tr> | ||
| <td align="left"><code>Generic</code></td> | ||
| <td align="left"><code>Bool | Number | Flexible | Object</code></td> | ||
| <td align="left">Top-level union for this module.</td> | ||
| </tr> | ||
| </table> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.