TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #32 · 7 фев.

Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять: from timeit import timeit def t1(): # складываем 10 строк через + из переменной t = 'text' for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t2(): # склеиваем список строк через метод join arr = ['text'] * 10 for _ in range(1000): s = ''.join(arr) def t3(): # складываем через + но не из переменной а непосредственно инлайн объекты for _ in range(1000): s = 'text' + 'text' + 'text' + ... # всего 10 раз Теперь каждую строку склейки запустим по 10М раз >>> timeit(t1, number=10000) 0.21951690399964718 >>> timeit(t2, number=10000) 1.4978306379998685 >>> timeit(t3, number=10000) 0.2213820789993406 Хм, а нам говорили что через "+" это плохо и медленно ))) 😁 Тут стоит учитывать, что речь идёт о склейке множества длинных строк. Давайте изменим условия: def t4(): t = 'text'*100 for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t5(): arr = ['text'*100] * 10 for _ in range(1000): s = ''.join(arr) def t6(): for _ in range(1000): s = 'text'*100 + 'text'*100 + ... # всего 10 раз >>> timeit(t4, number=10000) 12.795130728000004 >>> timeit(t5, number=10000) 2.642637542999182 >>> timeit(t6, number=10000) 0.2184546610005782 Вот, уже другой разговор, сразу видна разница, в среднем в 6 раз. Но погодите, почему последний тест t6() по скорости такой же как и t3()? Ведь строки теперь в 100 раз длиннее! Это вопросы оптимизации кода, какие простые изменения ускоряют или замедляют выполнение программы. Мы столкнулись с примером обхода обращения к переменной. Например, именно так работает директива #define в С++, во время компиляции подставляя значение переменной вместо ссылки на неё. В Python это тоже работает, но часто ли вы сможете встретить такой способ работы со строками? К сожалению, способ почти только теоретический. В целом, тесты показали то, что мы хотели. Делаем выводы самостоятельно. Полный листинг 🌍 #tricks

Резултати

Пронајдени 3 слични објави

Пребарај: #sagaftra

当前筛选 #sagaftra清除筛选
AI & Law

@ai_and_law · Post #362 · 29.07.2024 г., 07:04

Video Game Performers Strike Over AI Concerns Hollywood’s video game performers have announced a strike, following the breakdown of contract negotiations with major game studios over AI protections. This strike, organized by the Screen Actors Guild-American Federation of Television and Radio Artists (SAG-AFTRA), marks the second work stoppage for video game voice actors and motion capture performers. Despite progress on wages and job safety, SAG-AFTRA negotiators remain at an impasse with gaming giants such as Activision, Warner Bros., and Walt Disney Co. over the regulation of generative AI. Audrey Cooling, a spokesperson for the video game producers, stated that studios have proposed AI protections. However, SAG-AFTRA’s negotiating committee highlights a critical issue: the studios’ narrow definition of “performer,” which excludes many physical performances from protection, treating them instead as mere "data." Ray Rodriguez, SAG-AFTRA’s Chief Contracts Officer, emphasized that the industry’s stance undermines the rights of many performers, reflecting a significant challenge in the evolving landscape of AI in entertainment. #AI#SAGAFTRA#AIRegulation

AI & Law

@ai_and_law · Post #386 · 30.08.2024 г., 07:04

California Takes a Stand: New Bill to Protect Performers from AI Replicas The California Senate has approved AB 2602, a groundbreaking bill requiring explicit consent from performers before creating digital replicas of their likeness across TV, film, video games, audiobooks, and commercials. This legislation represents a significant victory for SAG-AFTRA in its ongoing battle against unauthorized AI use in the entertainment industry. Duncan Crabtree-Ireland, SAG-AFTRA's executive director, hailed the bill as "a huge step forward" in establishing safeguards against potential licensing abuse. While this marks a critical development, the bill still awaits Governor Gavin Newsom’s signature to become law. If enacted, it could set a new standard for AI ethics and performer rights, reflecting California’s leadership in balancing innovation with human protection. #AI#DigitalRights#SAGAFTRA#AIEthics

AI & Law

@ai_and_law · Post #173 · 24.11.2023 г., 08:04

SAG-AFTRA's Post-Strike Contract Raises Alarms on AI Usage Hello, dear subscribers! The tentative agreement between SAG-AFTRA and the Alliance of Motion Picture and Television Producers (AMPTP) that signals the potential end to the ongoing labor strike has taken an unexpected turn. While there's hope for the strike to conclude, concerns are emerging regarding the contract's stance on the use of artificial intelligence and its potential impact on actors. Disagreements over the digital capture, perpetual ownership, and usage of actors' likenesses by Hollywood studios have been key reasons behind the strike. The tentative contract introduces provisions related to generative AI technology, sparking worries about the extent of responsibility placed on studios. The contract's ambiguous wording around "unprecedented provisions for consent and compensation that will protect members from the threat of AI" has raised questions about how effectively it safeguards actors. Notably, nearly 14% of SAG-AFTRA's National Board opposed moving forward, indicating reservations within the union. The agreement introduces new definitions for digital replicas, emphasizing the need for clear and advance consent from actors. However, critics, including former SAG-AFTRA board member Justine Bateman, express concerns about potential loopholes favoring studios. The summary's of tentative agreement mention of actors potentially competing with AI objects for roles is seen as a significant drawback. While the strike officially ended on November 9th, the summary specifies that AMPTP only has to "endeavor to comply" until the contract is ratified. The lack of detail on enforcement mechanisms and the expansive powers given to studios in post-production edits raise concerns about actors' control over their digital replicas. As the union heads toward a ratification vote on December 5th, many questions remain unanswered. The summary's lack of clarity on specific terms for substantial changes triggering contractual mechanisms raises uncertainties about the practicalities of AI usage in the industry. #SAGAFTRA#AI#EntertainmentIndustry#LaborStrike#DigitalReplicas