# Custom \`id\` for \`RuntimeGeneratedFunction\`

**URL:** <https://discourse.julialang.org/t/custom-id-for-runtimegeneratedfunction/130129>\
**Category:** General Usage\
**Created:** [June 23, 2025, 11:29am UTC](https://discourse.julialang.org/t/custom-id-for-runtimegeneratedfunction/130129 "2025-06-23T11:29:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sstroemer](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Post date:** [June 23, 2025, 11:29am UTC](https://discourse.julialang.org/t/custom-id-for-runtimegeneratedfunction/130129/1 "2025-06-23T11:29:20Z")

</div>

I have a code that calls

```julia
code_ex = Meta.parse("""begin\n$(code)\nend""")

@RuntimeGeneratedFunction(
        :(function ( __virtual__ ::Virtual)
            # [...]
            try
                $code_ex
            catch e
                # [...]
            end
            return nothing
        end)
    )

```

which leads to around 75% of the total execution time (which includes a lot of other things) being spent here, specifically in converting the function’s body to an internal id in the constructor ([line 61](https://github.com/SciML/RuntimeGeneratedFunctions.jl/blob/49bab0340504c7c6a9a42bfd47c5e05d64018ddd/src/RuntimeGeneratedFunctions.jl#L61)), which is spent on serializing the expression ([line 284](https://github.com/SciML/RuntimeGeneratedFunctions.jl/blob/49bab0340504c7c6a9a42bfd47c5e05d64018ddd/src/RuntimeGeneratedFunctions.jl#L284)) to hash it.

What’s the best way to “skip” this step? I can guarantee (for my own package) knowing whether a function was already generated in advance much faster – of course I could build up my own cache on top of that, but I wanted to see if there was an “official” way to, e.g., provide custom ids, etc.

* * *

edit 01: Also, even when adding a manual cache, the overhead of creating the id once is a considerable amount of time that I would like to prevent.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 23, 2025, 2:14pm UTC](https://discourse.julialang.org/t/custom-id-for-runtimegeneratedfunction/130129/2 "2025-06-23T14:14:29Z")

</div>

I don’t think there is a way to skip that in the current package. I would accept a PR though that allows for some direct choice of ID instead of a hash.
