I want to understand Recompile

Recompile → when you change some code and go back into Unity.
I want to know what exactly happens there.
When I change some code, it seems like the entire asset-database is reimported, every single asset, because it get’s slower with every new asset.

Also it seems to destroy and recreate all classes.

Maybe I am wrong, idk. But assuming my observations are correct - why?

I only changed one script-file, why would it destroy all managed references and recreate it? 99.99% of them are still valid and will be absolutely identical when recreated. The same is true for Assets. They are exactly the same after reimporting, so why should it do that?

All this has to do with memory, right? Addresses on the RAM - they get destroyed and recreated. Can’t we just read on the ram, detect valid references/pointers and re-assign them, instead of destroying and recreating them? (except for the single file we changed of course)
Wouldn’t this increase iteration speed infinitely? Reimporting only assets which are known to have a certain script, recreating only those managed classes that are the same type or subclasses of the changed class.

Sounds as if the reimport speed would be pretty much the one of an entirely empty project with only one scriptfile inside.

Is this impossible? If so - why?

Thanks for your answers.

check your unity version and look at the known bugs. i recall there was this issue on some recent version where changing a script will reimport everything or something similar. that i think was fixed

What you’re talking about would be incremental compilation.

Unity half implemented it at some point, then abandoned it. Not sure why, but presumably they weren’t getting the results they wanted.