Liste des Groupes | Revenir à cl c |
Am 03.05.2024 um 01:21 schrieb Lawrence D'Oliveiro:
I/O performance certainly is possible with Python, and it has the high-
performance production-quality frameworks to prove it.
I thought about high performance code with >= 1e5 IOs/s.
That's not possible with Python.
Try it with something that has actual lexically-bound local variables
in it:
def factory(count : int) :
def counter() :
nonlocal count count += 1 return count
#end counter
#begin
return counter
#end factory
f1 = factory(3)
f2 = factory(30) print(f1())
print(f2())
print(f1())
print(f2())
output:
4
31
5
32
That should be similar:
#include <iostream>
#include <functional>
using namespace std;
function<int ()> factory()
{
return []
{
static int count = 0;
return ++count;
};
}
int main()
{
auto
f1 = factory(),
f2 = factory();
cout << f1() << endl;
cout << f2() << endl;
cout << f1() << endl;
cout << f2() << endl;
}
Les messages affichés proviennent d'usenet.