Skip to content

Performance micro optimizations #64

@cristianocca

Description

@cristianocca

The code can certain use some very small performance changes, which after summing up all changes it should improve performance slightly.
I'm talking about thinks like, use correct structures, more pytonic code, etc..

For example:

Using a list for just TWO elements: cuts = [rand_randint(1, len(gMom)-1), rand_randint(1, len(gMom)-1)]
Might be better just having two separate vars or a tuple.
This is in Crossovers

return True if rand_random() <= p else False in Util.py. Like really? Could be just return rand_random() <= p

Do not re calculate lengths every time, if you are planning on using len(something) many times, assign it to a variable first and then use it.

Define functions that are used in big loops, as a local variable, since doing var1.var2.somefunc on a loop is expensive due to look ups every time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions