Loading...
    • 개발자 가이드
    • API 참조
    • MCP
    • 리소스
    • 릴리스 노트
    Search...
    ⌘K
    리소스
    개요용어집시스템 프롬프트
    프롬프트 라이브러리Cosmic KeystrokesCorporate clairvoyantWebsite wizardExcel formula expertGoogle apps scripterPython bug busterTime travel consultantStorytelling sidekick출처 인용SQL sorcererDream interpreterPun-ditCulinary creatorPortmanteau poetHal the humorous helperLaTeX legendMood colorizerGit gudSimile savantEthical dilemma navigatorMeeting scribeIdiom illuminatorCode consultantFunction fabricatorNeologism creatorCSV converterEmoji encoderProse polisherPerspectives pondererTrivia generatorMindfulness mentorSecond-grade simplifierVR fitness innovatorPII purifierMemo maestroCareer coachGrading guruTongue twisterInterview question crafterGrammar genieRiddle me thisCode clarifierAlien anthropologistData organizerBrand builderEfficiency estimatorReview classifierDirection decoderMotivational museEmail extractorMaster moderatorLesson plannerSocratic sageAlliteration alchemistFuturistic fashion advisorPolyglot superpowersProduct naming proPhilosophical musingsSpreadsheet sorcererSci-fi scenario simulatorAdaptive editorBabel's broadcastsTweet tone detectorAirport code analyst
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    프롬프트 라이브러리

    코드 컨설턴트

    Python 코드 성능을 최적화하기 위한 개선 사항을 제안합니다.

    이 프롬프트를 개발자 Console에 복사하여 직접 시도해보세요!

    내용
    System제공된 Python 코드 스니펫을 분석하고 성능을 최적화하기 위한 개선 사항을 제안하는 것이 당신의 임무입니다. 코드를 더 효율적이고, 빠르고, 리소스 집약적이지 않게 만들 수 있는 영역을 식별하세요. 이러한 변경 사항이 코드의 성능을 어떻게 향상시킬 수 있는지에 대한 설명과 함께 최적화를 위한 구체적인 제안을 제공하세요. 최적화된 코드는 향상된 효율성을 보여주면서 원래 코드와 동일한 기능을 유지해야 합니다.
    Userdef fibonacci(n):
    if n <= 0:
    return []
    elif n == 1:
    return [0]
    elif n == 2:
    return [0, 1]
    else:
    fib = [0, 1]
    for i in range(2, n):
    fib.append(fib[i-1] + fib[i-2])
    return fib

    예시 출력

    Python
    def fibonacci(n):
        a, b = 0, 1
        for _ in range(n):
            yield a
            a, b = b, a + b
    

    설명: yield를 사용하는 제너레이터 함수는 피보나치 수열을 생성하는 데 더 메모리 효율적입니다. 전체 수열을 리스트에 생성하고 저장하는 것을 피합니다. 대신, 필요에 따라 각 숫자를 즉석에서 생성합니다.


    API 요청

    • API 요청