| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3e548af commit d1465d2
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,7 +107,7 @@ msgid "" | |||
| 107 | 107 | msgstr "" | |
| 108 | 108 | "A referência retornada é emprestada da tupla *p* (ou seja: ela só é válida " | |
| 109 | 109 | "enquanto você mantém uma referência a *p*). Para obter uma :term:`referência " | |
| 110 | - "forte`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) 1` ou :c:func:" | ||
| 110 | + "forte`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>` ou :c:func:" | ||
| 111 | 111 | "`PySequence_GetItem`." | |
| 112 | 112 | ||
| 113 | 113 | #: ../../c-api/tuple.rst:73 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4252,21 +4252,27 @@ msgstr "" | |||
| 4252 | 4252 | ||
| 4253 | 4253 | #: ../../faq/programming.rst:1993 | |
| 4254 | 4254 | msgid "How do I cache method calls?" | |
| 4255 | - msgstr "" | ||
| 4255 | + msgstr "Como faço para armazenar em cache as chamadas de um método?" | ||
| 4256 | 4256 | ||
| 4257 | 4257 | #: ../../faq/programming.rst:1995 | |
| 4258 | 4258 | msgid "" | |
| 4259 | 4259 | "The two principal tools for caching methods are :func:`functools." | |
| 4260 | 4260 | "cached_property` and :func:`functools.lru_cache`. The former stores results " | |
| 4261 | 4261 | "at the instance level and the latter at the class level." | |
| 4262 | 4262 | msgstr "" | |
| 4263 | + "As duas principais ferramentas para armazenamento em cache de métodos são :" | ||
| 4264 | + "func:`functools.cached_property` e :func:`functools.lru_cache`. A primeira " | ||
| 4265 | + "armazena resultados no nível de instância e a segunda no nível de classe." | ||
| 4263 | 4266 | ||
| 4264 | 4267 | #: ../../faq/programming.rst:2000 | |
| 4265 | 4268 | msgid "" | |
| 4266 | 4269 | "The *cached_property* approach only works with methods that do not take any " | |
| 4267 | 4270 | "arguments. It does not create a reference to the instance. The cached " | |
| 4268 | 4271 | "method result will be kept only as long as the instance is alive." | |
| 4269 | 4272 | msgstr "" | |
| 4273 | + "A abordagem *cached_property* funciona somente com métodos que não aceitam " | ||
| 4274 | + "nenhum argumento. Ela não cria uma referência para a instância. O resultado " | ||
| 4275 | + "do método será mantido em cache somente enquanto a instância estiver ativa." | ||
| 4270 | 4276 | ||
| 4271 | 4277 | #: ../../faq/programming.rst:2004 | |
| 4272 | 4278 | msgid "" | |
@@ -4275,20 +4281,30 @@ msgid "" | |||
| 4275 | 4281 | "accumulate, so too will the accumulated method results. They can grow " | |
| 4276 | 4282 | "without bound." | |
| 4277 | 4283 | msgstr "" | |
| 4284 | + "A vantagem é que, quando um instância não for mais usada, o resultado do " | ||
| 4285 | + "método armazenado em cache será liberado imediatamente. A desvantagem é " | ||
| 4286 | + "que, se as instâncias se acumularem, os resultados do método também serão " | ||
| 4287 | + "acumulados. Eles podem crescer sem limites." | ||
| 4278 | 4288 | ||
| 4279 | 4289 | #: ../../faq/programming.rst:2009 | |
| 4280 | 4290 | msgid "" | |
| 4281 | 4291 | "The *lru_cache* approach works with methods that have :term:`hashable` " | |
| 4282 | 4292 | "arguments. It creates a reference to the instance unless special efforts " | |
| 4283 | 4293 | "are made to pass in weak references." | |
| 4284 | 4294 | msgstr "" | |
| 4295 | + "A abordagem *lru_cache* funciona com métodos que têm argumento :term:" | ||
| 4296 | + "`hasheável`. Ele cria uma referência para a instância, a menos que sejam " | ||
| 4297 | + "feitos esforços especiais para passar referências fracas." | ||
| 4285 | 4298 | ||
| 4286 | 4299 | #: ../../faq/programming.rst:2013 | |
| 4287 | 4300 | msgid "" | |
| 4288 | 4301 | "The advantage of the least recently used algorithm is that the cache is " | |
| 4289 | 4302 | "bounded by the specified *maxsize*. The disadvantage is that instances are " | |
| 4290 | 4303 | "kept alive until they age out of the cache or until the cache is cleared." | |
| 4291 | 4304 | msgstr "" | |
| 4305 | + "A vantagem do algoritmo menos recentemente usado é que o cache é limitado " | ||
| 4306 | + "pelo *maxsize* especificado. A desvantagem é que as instâncias são mantidas " | ||
| 4307 | + "vivas até que saiam do cache ou até que o cache seja limpo." | ||
| 4292 | 4308 | ||
| 4293 | 4309 | #: ../../faq/programming.rst:2018 | |
| 4294 | 4310 | msgid "This example shows the various techniques::" | |
@@ -4318,20 +4334,49 @@ msgid "" | |||
| 4318 | 4334 | " \"Rainfall on a given date\"\n" | |
| 4319 | 4335 | " # Depends on the station_id, date, and units." | |
| 4320 | 4336 | msgstr "" | |
| 4337 | + "class Weather:\n" | ||
| 4338 | + " \"Procura informações de tempo em sites governamentais\"\n" | ||
| 4339 | + "\n" | ||
| 4340 | + " def __init__(self, station_id):\n" | ||
| 4341 | + " self._station_id = station_id\n" | ||
| 4342 | + " # O _station_id é privado e imutável\n" | ||
| 4343 | + "\n" | ||
| 4344 | + " def current_temperature(self):\n" | ||
| 4345 | + " \"Última observação horária\"\n" | ||
| 4346 | + " # Não armazena isso em cache porque os dados anteriores\n" | ||
| 4347 | + " # podem estar desatualizados.\n" | ||
| 4348 | + "\n" | ||
| 4349 | + " @cached_property\n" | ||
| 4350 | + " def location(self):\n" | ||
| 4351 | + " \"Retornas as coordenadas longitude/latitude coordinates da " | ||
| 4352 | + "estação\"\n" | ||
| 4353 | + " # Resultado depende apenas de station_id\n" | ||
| 4354 | + "\n" | ||
| 4355 | + " @lru_cache(maxsize=20)\n" | ||
| 4356 | + " def historic_rainfall(self, date, units='mm'):\n" | ||
| 4357 | + " \"Precipitação em uma determinada data\"\n" | ||
| 4358 | + " # Depende de station_id, date, e units." | ||
| 4321 | 4359 | ||
| 4322 | 4360 | #: ../../faq/programming.rst:2042 | |
| 4323 | 4361 | msgid "" | |
| 4324 | 4362 | "The above example assumes that the *station_id* never changes. If the " | |
| 4325 | 4363 | "relevant instance attributes are mutable, the *cached_property* approach " | |
| 4326 | 4364 | "can't be made to work because it cannot detect changes to the attributes." | |
| 4327 | 4365 | msgstr "" | |
| 4366 | + "O exemplo acima assume que o *station_id* nunca muda. Se os atribuitos " | ||
| 4367 | + "relevantes da instância forem mutáveis, a abordagem *cached_property* não " | ||
| 4368 | + "poderá usada porque não é capaz de detectar alterações no atributo." | ||
| 4328 | 4369 | ||
| 4329 | 4370 | #: ../../faq/programming.rst:2047 | |
| 4330 | 4371 | msgid "" | |
| 4331 | 4372 | "To make the *lru_cache* approach work when the *station_id* is mutable, the " | |
| 4332 | 4373 | "class needs to define the :meth:`~object.__eq__` and :meth:`~object." | |
| 4333 | 4374 | "__hash__` methods so that the cache can detect relevant attribute updates::" | |
| 4334 | 4375 | msgstr "" | |
| 4376 | + "Para que a abordagem *lru_cache* funcione quando *station_id* for mutável, a " | ||
| 4377 | + "classe precisa definir os métodos :meth:`~object.__eq__` e :meth:`~object." | ||
| 4378 | + "__hash__` para que o cache possa detectar atualizações relevantes do " | ||
| 4379 | + "atributo::" | ||
| 4335 | 4380 | ||
| 4336 | 4381 | #: ../../faq/programming.rst:2051 | |
| 4337 | 4382 | msgid "" | |
@@ -4355,6 +4400,25 @@ msgid "" | |||
| 4355 | 4400 | " 'Rainfall on a given date'\n" | |
| 4356 | 4401 | " # Depends on the station_id, date, and units." | |
| 4357 | 4402 | msgstr "" | |
| 4403 | + "class Weather:\n" | ||
| 4404 | + " \"Examplo com um identificador de estação mutável\"\n" | ||
| 4405 | + "\n" | ||
| 4406 | + " def __init__(self, station_id):\n" | ||
| 4407 | + " self.station_id = station_id\n" | ||
| 4408 | + "\n" | ||
| 4409 | + " def change_station(self, station_id):\n" | ||
| 4410 | + " self.station_id = station_id\n" | ||
| 4411 | + "\n" | ||
| 4412 | + " def __eq__(self, other):\n" | ||
| 4413 | + " return self.station_id == other.station_id\n" | ||
| 4414 | + "\n" | ||
| 4415 | + " def __hash__(self):\n" | ||
| 4416 | + " return hash(self.station_id)\n" | ||
| 4417 | + "\n" | ||
| 4418 | + " @lru_cache(maxsize=20)\n" | ||
| 4419 | + " def historic_rainfall(self, date, units='cm'):\n" | ||
| 4420 | + " \"Precipitação em uma determinada data\"\n" | ||
| 4421 | + " # Depende de station_id, date, e units." | ||
| 4358 | 4422 | ||
| 4359 | 4423 | #: ../../faq/programming.rst:2073 | |
| 4360 | 4424 | msgid "Modules" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,10 +45,10 @@ | |||
| 45 | 45 | - newtypes_tutorial.po 25 / 177 ( 14.0% translated). | |
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | - # faq (94.80% done) | ||
| 48 | + # faq (95.72% done) | ||
| 49 | 49 | ||
| 50 | 50 | - library.po 157 / 162 ( 96.0% translated). | |
| 51 | - - programming.po 456 / 508 ( 89.0% translated). | ||
| 51 | + - programming.po 466 / 508 ( 91.0% translated). | ||
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | 54 | # howto (57.69% done) | |
@@ -295,5 +295,5 @@ | |||
| 295 | 295 | - 3.7.po 252 / 568 ( 44.0% translated). | |
| 296 | 296 | ||
| 297 | 297 | ||
| 298 | - # TOTAL (64.87% done) | ||
| 298 | + # TOTAL (64.89% done) | ||
| 299 | 299 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1 @@ | |||
| 1 | - {"translation": "54.15%", "total": 72631, "updated_at": "2025-01-18T23:27:34+00:00Z"} | ||
| 1 | + {"translation": "54.15%", "total": 72631, "updated_at": "2025-01-19T23:27:06+00:00Z"} | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments