Extending Python to support a hardware implementation of content addressible memory

Pythojn is abytecode iterpreter - I should have thought of that.

Then it is likely this is an extension to the bytecode.

Do libraries have the capability to alter the way existing data types are processed ?
Your suggesting they do - if so that is fine. Any pointers to documentation howtos examples regarding modules ?
Particularly with respect to extending the behavior of existing data types ?

Syntax is unimportant to me. That is not the same as this does not involve syntax.

If I were to say “I am looking to extend the language so that floats can be used as the indexes to traditional arrays. Never mind that I can not think of a reason for doing so, would that be implimented as an API or a module.
What I am looking to do is to treat indexing like an operator - like "
+” or “-” and overloading it so that something other than integers can be used as indexes.

Or another way of thinking of this - and maybe Python already has this and I just need to modify that implimentation, is Content addessing is similar to Hashes in Perl - hashes in Perl is a form of Content addressing, it is not the same as a hash function, though I suspect perl impliments CA using hashing internally, - except that it is supported directly by the hardware. I have described CA as key-value, which is how a perl hash works. But traditional array indexing is also key-value
where the integer index is the key.

This is not an API, it is not a data type, it si an attribiute of any data type that specifies a different implimentation of load/store.

Python indeed has such a type, it’s called a dict, short for dictionary.

If you really wanted, you could delve into the implementation of dicts
in the interpreter and give them an attribute that switches them to
being implemented using your CAM.

But it would be much easier to add a new type that has the same
interface as a dict but a different implementation.

You say that you would set this attribute when you create the object.
Presumably it’s not something you would want to change later on. If
that’s true, then you know when you create the object that you want it
to be a CAM-implemented one rather than a standard one. So why can’t you
just create an object of a different type at that point?

1 Like

You are seriously overthinking this–back up a step. :slight_smile: You don’t need to modify bytecode or the interpreter at all.

You can overload indexing by implementing __getitem__. You can do that in Python itself or in a C extension (by writing PyObject_GetItem). Internally your method can implement the lookup however it likes.

Regarding documentation on modules and so on, I’d just start with the tutorial.

2 Likes

@dhlii if you already have a C or Rust library that either (1) implements a simulation of your hardware or (2) directly interfaces with the memory hardware (I assume you must have (2) already), then the fastest way forward to also expose this in Python would be to give this to a moderately experienced Python programmer (someone who has implemented some extension modules) and ask them to do this for you.

If you really want the fastest way forward. :wink: This isn’t an incredibly complex problem but it’s not trivial either and the people who can do it usually have other jobs.

1 Like

Several posts were blocked - Am I violating some community standards I am not aware of ?

No we just went on a tangent, not your fault!

What we have now is a C preprocessor. I was starting to migrate that into GCC when our AI person told us that pretty much everything AI is in python. So I am here. We have done lots of FPGA and spoftware simulations - proving the fundimental implimentation. We are now trying to connect our work to real world problems in real world languages. We are in the process of shifting to better FPGA;s for hardware simulation so we can simulate larger memory.
And so we can test some ideas that are not in the papers yet.
It is also important to start with real application code solving real world problems

It sounds like your AI person might not understand how those libraries are actually implemented. Almost always, they provide a python interface to code written in other languages.

4 Likes