Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move initializing animals out of __init__ to global scope. #85

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

NHDaly
Copy link
Contributor

@NHDaly NHDaly commented Aug 6, 2018

Before, having __init__ read from the filesystem was causing problems with
static compiling.

So I've just moved the initialization out of the __init__ function, and deleted the now-empty function entirely.

Per the julia docs, intializing an array like this doesn't need to be in
__init__ anway, the whole array can be serialized during precompilation.

Here's the relevant section (from Module-initialization-and-precompilation):

Constants involving most Julia objects that are not produced by ccall
do not need to be placed in init: their definitions can be
precompiled and loaded from the cached module image. This includes
complicated heap-allocated objects like arrays. However, any routine
that returns a raw pointer value must be called at runtime for
precompilation to work (Ptr objects will turn into null pointers
unless they are hidden inside an isbits object). This includes the
return values of the Julia functions cfunction and pointer.

Having `__init__` read from the filesystem was causing problems with
static compiling.

Per the julia docs, intializing an array like this doesn't need to be in
__init__, the whole array can be serialized during precompilation:

> Constants involving most Julia objects that are not produced by ccall
> do not need to be placed in __init__: their definitions can be
> precompiled and loaded from the cached module image. This includes
> complicated heap-allocated objects like arrays. However, any routine
> that returns a raw pointer value must be called at runtime for
> precompilation to work (Ptr objects will turn into null pointers
> unless they are hidden inside an isbits object). This includes the
> return values of the Julia functions cfunction and pointer.
@NHDaly
Copy link
Contributor Author

NHDaly commented Aug 14, 2018

Hey Mike,

Friendly ping! :) This should be a noop for your package, and will allow it to be statically compiled! :D

Cheers!
~Nathan

@NHDaly
Copy link
Contributor Author

NHDaly commented Aug 21, 2018

I should add that this is a follow-up to #77 which helped, but didn't solve the problem.

@MikeInnes MikeInnes merged commit 9921e1f into FluxML:master Oct 8, 2018
@MikeInnes
Copy link
Member

👍 Thanks!

@NHDaly NHDaly deleted the init_animals branch October 8, 2018 17:18
@NHDaly
Copy link
Contributor Author

NHDaly commented Oct 8, 2018

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants