Comments (6)
@robertwb changed owner from robertwb
to somebody
commented
from cython.
@garyfurnish commented
One of the first things I do is make my own c wrappers for creating objects. Even with the expensive new call the savings it noticeable.
from cython.
@robertwb changed milestone to wishlist
commented
from cython.
scoder changed description from
When subclasses of extension types call the init() method of their supertype, Cython generates code that looks up the "init" attribute of the instance and then calls it through Python using arg tuple/kwargs. This is because the special init() method ("tp_init" slot) uses this call signature.
Cython should recognise calls to this method and at least call it directly.
In the (presumably very common) case that the arguments do not use starargs, a more advanced approach would be to split the init() method into an internal plain C-function replacement and a tp_init wrapper, and then call the internal function directly, without doing any tuple packing etc. Not sure if it's worth it, though, as the call is already preceded by an (expensive) object allocation.
to
When subclasses of extension types call the __init__()
method of their supertype, Cython generates code that looks up the "__init__
" attribute of the instance and then calls it through Python using arg tuple/kwargs. This is because the special __init__()
method ("tp_init
" slot) uses this call signature.
Cython should recognise calls to this method and at least call it directly.
In the (presumably very common) case that the arguments do not use starargs, a more advanced approach would be to split the __init__()
method into an internal plain C-function replacement and a tp_init
wrapper, and then call the internal function directly, without doing any tuple packing etc. Not sure if it's worth it, though, as the call is already preceded by an (expensive) object allocation.
commented
The same idea is reported in http://trac.cython.org/ticket/141. This should use cpdef semantics.
from cython.
scoder commented
The same applies to other special methods like __call__
. (noted here to close http://trac.cython.org/ticket/141 as a duplicate)
from cython.
scoder commented
The test in tests/run/special_methods_T561.pyx has some test code for this:
from cython.
Related Issues (20)
- [BUG] Complex function argument lists causing MSVC to fail HOT 10
- [BUG] Enabling limited API attempts to take the size of an opaque object HOT 11
- [ENH] Conditional Compilation HOT 2
- Migrating notes on Cython wrappers from SciPy wiki
- PyUnicode_AsUnicode missing Error with Python 3.12 on Windows HOT 5
- Use `Py_IncRef()` and `Py_DecRef()` in Limited API
- [BUG] Access violation using cython.ufunc with cimport numpy HOT 3
- [BUG] Regression in cython 3.0.9 HOT 3
- [BUG] Can not do logic with `char *` ? HOT 2
- [BUG] Compiler crash using ufunc with multiple, fused return types HOT 1
- [BUG] `TypeError` when using type annotations in signatures with defaults HOT 4
- Document compilation caching? HOT 10
- A number of warning messages during docs make build procedure HOT 6
- [BUG] Test failures with NumPy 2.0b1
- [BUG] `int` power of an `int` results a `float` when computed inside a list comprehension HOT 1
- [BUG] segfault when raising an exception with python 3.13 alpha 5 HOT 2
- Limited API preview branch HOT 3
- [ENH] __Pyx_PyDict_Pack function (for code size)?
- [BUG] Bug with limited API support in trivial program involving float literal HOT 5
- [BUG] Segmentation fault with Walrus-Operator and same named variables HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cython.