| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Closes https://github.com/cython/cython/issues/5399
|
| |
|
| |
|
|
|
| |
Closes https://github.com/cython/cython/issues/5070
|
|
|
|
|
| |
declaration (#5248)
Co-authored-by: GalaxySnail <me@glxys.nl>
|
|
|
| |
Parallelization tutorial to try to explain prange/parallel in a little more user-friendly way
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #1839
cdef public functions should be declared with the appropriate linkage:
* in C mode, either extern or extern "C", depending on whether the header file is included in (resp. object code is linked against) a C or a C++ compilation unit. Choice is made at compile-time through #ifdef __cplusplus macros. NB: This is the current behavior.
* in C++ mode, extern "C++" is the only option, as C code cannot call C++ code. Note that extern "C++" should be preferred over extern to allow users to #include the C++ header inside a extern "C" block (which is legal, although barely used).
Note that the current behavior is OK for C mode, but is incorrect for the C++ mode. As described in #1839, this incorrect behavior is diagnosed by compilers emitting warnings when cdef public functions return a C++ type (e.g. std::vector).
The test introduced in this PR checks that the current behavior for C mode (with both C and C++ compatibility) is preserved, and that the behavior for C++ mode is fixed.
|
|
|
|
| |
documentation in language basics userguide (#5082)
|
| |
|
| |
|
|
|
| |
To make sure it works right with Python 3 semantics.
|
| |
|
| |
|
|
|
| |
and remove note about bug
|
|
|
|
|
|
|
| |
* Replace unnecessary __cinit__ with __init__ in documentation examples
* Use __cinit__ when necessary in the wrapping C++ examples
* Modify existing Rectangle instead of creating a new Rectangle in the pointer to Rectangle example
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Check for "Optional[ctype]" earlier because we need to make sure that "Optional[int]" etc. interprets "int" as (valid) Python int type and not (invalid) C int type.
See https://github.com/cython/cython/issues/3883
* Fix typing assumptions in PEP 526 variable annotations test: in a Python type annotation, "int" means Python int and "float" means Python float, not the C types.
* Use a context manager to make it explicit in annotation type analysis when C types are allowed, and when Python types are required or expected.
* Generalise the concept of equivalent Python and C types for more efficient type inference: PyFloat/double, PyBool/bint, PyComplex/double complex.
* Refactor analyse_type_annotation() to prepare the extraction of type modifiers (as opposed to special types).
See discussion in https://github.com/cython/cython/pull/4606#issuecomment-1026658869
* Refactor handling of "typing.Optional", "dataclasses.InitVar" etc. annotations to move them into the declared Entry during type analysis and keep only the bare type in the type system.
* Force ClassVar[...] types to be object types.
* Add a warning when users define a ClassVar[] with a non-Python type.
See https://github.com/cython/cython/pull/4606#discussion_r805170982
* Provide a helpful warning when users write plain C types in a non-C annotation context.
* Only consider Python object item types from list/tuple as self.type in IndexNode since that will be the result of the index access. Coercion needs to happen externally, then based on the type inference.
* Ignore Python annotation type "long" since it almost certainly does not refer to PyLong but to C long. Issue a warning to make users aware of it.
* Fix PEP-526 test by working around incomplete type inference, but leave FIXME comments.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Initial migration of examples
* Migrate text in sharing_declarations.rst
* Some fixes of examples and clarification
* Fix capitalization
* Apply suggestions from code review
Co-authored-by: da-woods <dw-git@d-woods.co.uk>
Co-authored-by: da-woods <dw-git@d-woods.co.uk>
|
|
|
|
|
| |
* Migrate special_methods.rst to pure python
* Fix missing import in examples
|
|
|
|
| |
Signatures with unnamed (type-only) arguments are generally more difficult to read.
|
|
|
|
|
|
| |
specific struct fields.
See https://github.com/cython/cython/issues/4310
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
New decorator/function "@cython.dataclasses.dataclass" and "cython.dataclasses.field()" to mark dataclasses and their fields.
Tries to match the interface provided by a regular dataclass as much as possible.
This means taking the types from the dataclasses module if available (so they match exactly) or a fallback Python version that just implements the core parts (executed with "PyRun_String()" in the C source).
Use of placeholders in generated "__init__" code means the code in the C file isn't hugely readable. Probably not a huge issue, but don't really see a way round that.
As part of this I've also also implemented a Cython version of "typing.ClassVar". Although really designed for use with dataclasses it behaves sensibly when used in types in a normal cdef class. This is worth documenting more thoroughly.
Closes https://github.com/cython/cython/issues/2903
|
| |
|
|
|
| |
Closes https://github.com/cython/cython/issues/2760
|
|
|
| |
Arguably, it's unnecessary if the auto-call works correctly, but if we're still advising users to do it themselves then it probably should be in the docs.
|
|
|
|
| |
(GH-4316)
|
| |
|
|
|
| |
See https://github.com/cython/cython/issues/4187
|
| |
|
| |
|
| |
|
|
|
|
| |
(cdef_classes.rst) (GH-4232)
|
| |
|
| |
|
|
|
|
|
|
| |
exceptions.
Also make a couple of improvements regarding clarity and text formatting.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
(cython_tutorial.rst) (GH-4226)
See https://github.com/cython/cython/issues/4187
* .gitignore: add directory for docs build and cython_debug
* doc-requirements.txt: add sphinx-tabs
* conf.py: add and setup sphinx-tabs extension
* Create _static\css\tabs.css for customisation
* add "two-syntax-variants-used" file as a preface about the different typing variants
|
|
|
|
| |
them importable in Python (although not necessarily runnable).
|
|
|
| |
For reasons I don't full understand, including "windows.h" seems to break everything. There's an alternative sleep function in stdlib.h so I've used that instead since it makes the point just as well.
|
|
|
|
|
| |
* DOC: make some github issues into links, doc fixes
* add a doc-requirements.txt for building docs
* use ':issue:' domains for github issues
|
| |
|
| |
|
|
|
|
|
| |
"synchapi.h" is not supposed to be included directly, and "windows.h" can break ... other stuff.
Let's see what we can do.
|
| |
|
| |
|
|
|
|
| |
documentation.
|
| |
|