Title: RFC: Change `__cuda_stream__` from class attribute to method · Issue #348 · NVIDIA/cuda-python · GitHub
Open Graph Title: RFC: Change `__cuda_stream__` from class attribute to method · Issue #348 · NVIDIA/cuda-python
X Title: RFC: Change `__cuda_stream__` from class attribute to method · Issue #348 · NVIDIA/cuda-python
Description: One of the reasons that people complain about CUDA Array Interface (CAI) being slow is because it has side effects. Consider this example: >>> class KKK: ... @property ... def __proppp__(self): ... print("I am called") ... >>> >>> type(K...
Open Graph Description: One of the reasons that people complain about CUDA Array Interface (CAI) being slow is because it has side effects. Consider this example: >>> class KKK: ... @property ... def __proppp__(self): ......
X Description: One of the reasons that people complain about CUDA Array Interface (CAI) being slow is because it has side effects. Consider this example: >>> class KKK: ... @property ... def __proppp__(s...
Opengraph URL: https://github.com/NVIDIA/cuda-python/issues/348
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RFC: Change `__cuda_stream__` from class attribute to method","articleBody":"One of the reasons that people complain about CUDA Array Interface (CAI) being slow is because it has side effects. Consider this example:\n```python\n>>> class KKK:\n... @property\n... def __proppp__(self):\n... print(\"I am called\")\n... \n>>> \n>>> type(KKK.__proppp__)\n\u003cclass 'property'>\n>>> k = KKK()\n>>> hasattr(k, \"__proppp__\")\nI am called\nTrue\n```\nOne can see that the `hasattr` call on any class attribute/property would actually execute the attribute implementation, but not if it is a method:\n```python\n>>> class KKK:\n... def __proppp__(self):\n... print(\"I am called\")\n... \n>>> \n>>> type(KKK.__proppp__)\n\u003cclass 'function'>\n>>> k = KKK()\n>>> hasattr(k, \"__proppp__\")\nTrue\n```\nI realized I had forgotten about this during the design stage until now. This fact has also been [pointed out by @gmarkall](https://big-grey.co.uk/2020/02/27/surprises-with-hasattr-and-the-property-decorator/) (back in the days of designing CAI, IIRC).\n\nI propose to change `__cuda_stream__` and any future protocols to a callable class method from a class property/attribute so as to avoid side effects (thereby reducing overhead) and establish a future-proof convention, following DLPack and other protocols.","author":{"url":"https://github.com/leofang","@type":"Person","name":"leofang"},"datePublished":"2025-01-03T20:28:04Z","url":"https://github.com/NVIDIA/cuda-python/issues/348"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8afbea78-830e-9a91-2062-4a631297ac6b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B96E:17181A:11CF9F9:17A07FA:6AF886CC |
| html-safe-nonce | 5f05da85388d9966d086f087e211fb9fd299856665cfcb5245bf76761a99d9f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTZFOjE3MTgxQToxMUNGOUY5OjE3QTA3RkE6NkFGODg2Q0MiLCJ2aXNpdG9yX2lkIjoiMzgyNjI0MTEwNTcxMjE1NDMxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4059e48778fdb4c0aca53a9b5e9a9ba6f2702fb10638be380fe5eb15961c2471 |
| hovercard-subject-tag | issue:2768131353 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NVIDIA/cuda-python/348/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e99be3fdeeb056e99790f7a666581ac1b597f225c656fe6a06fce4070ec70341/NVIDIA/cuda-python/issues/348 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e99be3fdeeb056e99790f7a666581ac1b597f225c656fe6a06fce4070ec70341/NVIDIA/cuda-python/issues/348 |
| og:image:alt | One of the reasons that people complain about CUDA Array Interface (CAI) being slow is because it has side effects. Consider this example: >>> class KKK: ... @property ... def __proppp__(self): ...... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | leofang |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/NVIDIA/cuda-python git https://github.com/NVIDIA/cuda-python.git |
| octolytics-dimension-user_id | 1728152 |
| octolytics-dimension-user_login | NVIDIA |
| octolytics-dimension-repository_id | 381173759 |
| octolytics-dimension-repository_nwo | NVIDIA/cuda-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 381173759 |
| octolytics-dimension-repository_network_root_nwo | NVIDIA/cuda-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width