|
|
Subscribe / Log in / New account

An introduction to asynchronous Python

An introduction to asynchronous Python

Posted Jun 29, 2017 19:51 UTC (Thu) by epa (subscriber, #39769)
In reply to: An introduction to asynchronous Python by zlynx
Parent article: An introduction to asynchronous Python

Interesting point. This suggests that if you are going to use reference counting, the counts should be stored separately from the object, in some kind of global array or global lookup of address to count. Then they will be in their own pages, while the objects themselves stay mostly read-only.


to post comments

An introduction to asynchronous Python

Posted Jun 29, 2017 22:49 UTC (Thu) by excors (subscriber, #95769) [Link]

I think std::shared_ptr can sort of do this already - you can pass the constructor a raw pointer (allocated however you want) plus an allocator object that will be used for internal allocations (i.e. refcount storage etc), and you could make that allocator use a separate pool to keep all the refcounts together. Then wrap it all in a custom type so users don't have to think about it.

(Apparently constructing a shared_ptr via std::make_shared is special - that does a single allocation to contain both the refcount and the object, which is usually a good idea, but in this case you'd need to implement it differently, which should be easy enough.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds