{{ some_date|naturaltime|safe }}
root.mainloop()
Его нельзя останавливать, иначе приложение зависнет. А блокирующий вызов x.join()
как раз это и делает.from functools import partial
import threading
import time
import tkinter as tk
from tkinter.ttk import Progressbar
import queue
def worker(q, r):
for i in range(100):
# Передаём в очередь текущее значение
q.put(i + 1)
# Генерируем событие
r.event_generate('<<Updated>>', when='tail')
# Спим для наглядности
time.sleep(0.1)
def on_update(event, q=None, pb=None):
# Получаем данные из очереди
pb['value'] = q.get()
# Создаём очередь для обмена данными между поткоами
q = queue.Queue()
# Создаём окно
root = tk.Tk()
progressbar = Progressbar(root, orient=tk.HORIZONTAL, length=100, mode='determinate')
progressbar.pack()
# "Передаём" в обработчик ссылки на очередь и progressbar
handler = partial(on_update, q=q, pb=progressbar)
# Регистрируем обработчик для события обновления progressbar'а
root.bind('<<Updated>>', handler)
# Создаём поток и передаём в него ссылки на очередь и окно
t = threading.Thread(target=worker, args=(q, root))
t.start()
root.mainloop()
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<div sec:authorize="hasRole('ROLE_ADMIN')">
This content is only shown to administrators.
</div>
Не верю, что среда jvm когда-либо научится использовать ресурсы системы оптимальнее чем нативная платформа.
These days we’re beating the really good C and C++ compilers pretty much always. When you go to the dynamic compiler, you get two advantages when the compiler’s running right at the last moment. One is you know exactly what chipset you’re running on. So many times when people are compiling a piece of C code, they have to compile it to run on kind of the generic x86 architecture. Almost none of the binaries you get are particularly well tuned for any of them. You download the latest copy of Mozilla,and it’ll run on pretty much any Intel architecture CPU. There’s pretty much one Linux binary. It’s pretty generic, and it’s compiled with GCC, which is not a very good C compiler.
When HotSpot runs, it knows exactly what chipset you’re running on. It knows exactly how the cache works. It knows exactly how the memory hierarchy works. It knows exactly how all the pipeline interlocks work in the CPU. It knows what instruction set extensions this chip has got. It optimizes for precisely what machine you’re on. Then the other half of it is that it actually sees the application as it’s running. It’s able to have statistics that know which things are important. It’s able to inline things that a C compiler could never do. The kind of stuff that gets inlined in the Java world is pretty amazing. Then you tack onto that the way the storage management works with the modern garbage collectors. With a modern garbage collector, storage allocation is extremely fast.
for
- это вполне питонично. a = [
['Саша', 'М', 1993],
['Маша', 'Ж', 1990],
['Паша', 'М', 1995],
...
]
current_year = date.today().year
b = [[n, s, current_year - b] for n, s, b in a]
b = list(map(lambda i: [i[0], i[1], current_year - i[2]], a))
b = list(starmap(lambda n, s, b: [n, s, current_year - b], a))