AlgebraicJulia / AlgebraicJulia/Catlab.jl

Function `ports` is not type stable.

Abierto
#803 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Julia
Estrellas
724
Forks
73
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Consider the following two functions:

```
using Catlab.WiringDiagrams

wd = singleton_diagram(UntypedUWD, 1000000);

function collect_ports_1(wd)
ps = Int[]
for i in ports(wd)
push!(ps, i)
end
ps
end

function collect_ports_2(wd)
ps = Int[]
for i in ports(wd)::UnitRange{Int}
push!(ps, i)
end
ps
end
```

Then, on my machine,
```
collect_ports_1(wd)
@time collect_ports_1(wd);
```
outputs `0.051219 seconds (3.00 M allocations: 70.801 MiB)`.

On the other hand,
```
collect_ports_2(wd)
@time collect_ports_2(wd);
```
outputs `0.004928 seconds (17 allocations: 9.782 MiB)`.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.