Skip to content

Commit 563e799

Browse files
committed
Delay importing torch & friends
time python -c 'import cuda.tile' Before/after: real 0m1.142s / 0m0.054s Additionally, optimize the steam argument parsing in launch(). Adding a simple cache shaves off about 50 nanos. Signed-off-by: Greg Bonik <gbonik@nvidia.com>
1 parent de4a85c commit 563e799

4 files changed

Lines changed: 207 additions & 179 deletions

File tree

cext/py.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ void log_python_error(const char* filename, int line, const char* level, SavedEx
244244
#define LOG_PYTHON_ERROR(level, exc, ...) \
245245
log_python_error(__FILE__, __LINE__, level, exc, __VA_ARGS__)
246246

247+
static inline PyPtr getattr(PyObject* obj, PyObject* attrname) {
248+
return steal(PyObject_GetAttr(obj, attrname));
249+
}
250+
247251
static inline PyPtr getattr(PyObject* obj, const char* attrname) {
248252
return steal(PyObject_GetAttrString(obj, attrname));
249253
}

0 commit comments

Comments
 (0)