lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.47k stars 157 forks source link

Seeded random.random() with system clock if it is left unseeded #2549

Closed advikkabra closed 3 months ago

advikkabra commented 5 months ago

Fixes #2545 . Has a _seed_set variable which checks if the seed has been explicitly set by the user, else will set the default seed to the system clock.

advikkabra commented 4 months ago

@certik Is this approach okay?

advikkabra commented 4 months ago

@Thirumalai-Shaktivel I've reverted the changes in random.py and created another function in lfortran_intrinsics which calls all initial setup. I think the PR is good to go.

Thirumalai-Shaktivel commented 4 months ago

I think the changes looks good to me. @Shaikh-Ubaid, Why don't you review this PR and share your thoughts?

Shaikh-Ubaid commented 4 months ago

Initially we can call it every time, later on we can update it to only call it if random is used.

I am concerned about calling it every time even when random() is not used. But since we can update it later, I think it is fine.

Thirumalai-Shaktivel commented 3 months ago

Thanks for the review, Ubaid!